CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
ActionExtenderTests.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="ReadWriteAuthorizationTests.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>no summary</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Collections.Generic;
10using System.Text;
11using Csla.Test.Security;
12using UnitDriven;
13using System.Diagnostics;
14
15#if NUNIT
16using NUnit.Framework;
17using TestClass = NUnit.Framework.TestFixtureAttribute;
18using TestInitialize = NUnit.Framework.SetUpAttribute;
19using TestCleanup = NUnit.Framework.TearDownAttribute;
20using TestMethod = NUnit.Framework.TestAttribute;
21#elif MSTEST
22using Microsoft.VisualStudio.TestTools.UnitTesting;
23#endif
24
26{
27#if TESTING
28 [DebuggerNonUserCode]
29 [DebuggerStepThrough]
30#endif
31 [TestClass()]
33 {
34
35 [TestMethod()]
36 [TestCategory("SkipWhenLiveUnitTesting")]
38 {
39 ApplicationContext.GlobalContext.Clear();
40
41 var personRoot = EditablePerson.NewEditablePerson();
42 using (var personForm = new PersonForm())
43 {
44 //allow read and write
45 personRoot.AuthLevel = 2;
46 personForm.BindUI(personRoot,true);
47 personForm.Show(); // must show form to get databinding to work properly
48
49 //ensure button state matches logical status
50 Assert.AreEqual(personForm.SaveButton.Enabled, true, "Default button state on new not correct");
51 Assert.AreEqual(personForm.CancelButton.Enabled, true, "Default button state on new not correct");
52 Assert.AreEqual(personForm.CloseButton.Enabled, true, "Default button state on new not correct");
53 Assert.AreEqual(personForm.ValidateButton.Enabled, true, "Default button state on new not correct");
54 }
55
56 personRoot = EditablePerson.GetEditablePerson(2);
57 using (var personForm = new PersonForm())
58 {
59 personForm.BindUI(personRoot,true);
60 personForm.Show(); // must show form to get databinding to work properly
61
62 //ensure button state matches logical status
63 Assert.AreEqual(personForm.SaveButton.Enabled, false, "Default button state on fetch not correct");
64 Assert.AreEqual(personForm.CancelButton.Enabled, false, "Default button state on fetch not correct");
65 Assert.AreEqual(personForm.CloseButton.Enabled, true, "Default button state on fetch not correct");
66 Assert.AreEqual(personForm.ValidateButton.Enabled, true, "Default button state on fetch not correct");
67 }
68 }
69
70 [TestMethod()]
71 [TestCategory("SkipWhenLiveUnitTesting")]
73 {
74 ApplicationContext.GlobalContext.Clear();
75
76 var personRoot = EditablePerson.GetEditablePerson(2);
77 using (var personForm = new PersonForm())
78 {
79 personForm.BindUI(personRoot,true);
80 personForm.Show(); // must show form to get databinding to work properly
81
82 //ensure button state matches logical status
83 Assert.AreEqual(personForm.SaveButton.Enabled, false, "Default button state on fetch not correct");
84 Assert.AreEqual(personForm.CancelButton.Enabled, false, "Default button state on fetch not correct");
85 Assert.AreEqual(personForm.CloseButton.Enabled, true, "Default button state on fetch not correct");
86 Assert.AreEqual(personForm.ValidateButton.Enabled, true, "Default button state on fetch not correct");
87
88 personForm.firstNameTextBox.Text = "";
89
90 Assert.AreEqual(personForm.SaveButton.Enabled, false, "Save button did not become disabled");
91 Assert.AreEqual(personForm.CancelButton.Enabled, true, "Cancel button is not enabled");
92 Assert.AreEqual(personForm.CloseButton.Enabled, true, "Button state is not correct");
93 Assert.AreEqual(personForm.ValidateButton.Enabled, true, "Button state is not correct");
94
95 personForm.firstNameTextBox.Text = "ABC";
96
97 Assert.AreEqual(personForm.SaveButton.Enabled, true, "Save button did not become enabled");
98 Assert.AreEqual(personForm.CancelButton.Enabled, true, "Cancel button is not enabled");
99 Assert.AreEqual(personForm.CloseButton.Enabled, true, "Button state is not correct");
100 Assert.AreEqual(personForm.ValidateButton.Enabled, true, "Button state is not correct");
101 }
102 }
103
104 [TestMethod()]
105 [TestCategory("SkipWhenLiveUnitTesting")]
107 {
108 ApplicationContext.GlobalContext.Clear();
109
110 var personRoot = EditablePerson.NewEditablePerson();
111 using (var personForm = new PersonForm())
112 {
113 //allow read and write
114 personRoot.AuthLevel = 2;
115 personForm.BindUI(personRoot,false);
116 personForm.Show(); // must show form to get databinding to work properly
117
118 //ensure button state matches logical status
119 Assert.AreEqual(personForm.saveToolStripButton.Enabled, true, "Default button state on new not correct");
120 Assert.AreEqual(personForm.cancelToolStripButton.Enabled, true, "Default button state on new not correct");
121 Assert.AreEqual(personForm.closeToolStripButton.Enabled, true, "Default button state on new not correct");
122 Assert.AreEqual(personForm.validateToolStripButton.Enabled, true, "Default button state on new not correct");
123 }
124
125 personRoot = EditablePerson.GetEditablePerson(2);
126 using (var personForm = new PersonForm())
127 {
128 personForm.BindUI(personRoot,false);
129 personForm.Show(); // must show form to get databinding to work properly
130
131 //ensure button state matches logical status
132 Assert.AreEqual(personForm.saveToolStripButton.Enabled, false, "Default button state on fetch not correct");
133 Assert.AreEqual(personForm.cancelToolStripButton.Enabled, false, "Default button state on fetch not correct");
134 Assert.AreEqual(personForm.closeToolStripButton.Enabled, true, "Default button state on fetch not correct");
135 Assert.AreEqual(personForm.validateToolStripButton.Enabled, true, "Default button state on fetch not correct");
136 }
137 }
138
139 [TestMethod()]
140 [TestCategory("SkipWhenLiveUnitTesting")]
142 {
143 ApplicationContext.GlobalContext.Clear();
144
145 var personRoot = EditablePerson.GetEditablePerson(2);
146 using (var personForm = new PersonForm())
147 {
148 personForm.BindUI(personRoot,false);
149 personForm.Show(); // must show form to get databinding to work properly
150
151 //ensure button state matches logical status
152 Assert.AreEqual(personForm.saveToolStripButton.Enabled, false, "Default button state on fetch not correct");
153 Assert.AreEqual(personForm.cancelToolStripButton.Enabled, false, "Default button state on fetch not correct");
154 Assert.AreEqual(personForm.closeToolStripButton.Enabled, true, "Default button state on fetch not correct");
155 Assert.AreEqual(personForm.validateToolStripButton.Enabled, true, "Default button state on fetch not correct");
156
157 personForm.firstNameTextBox.Text = "";
158
159 Assert.AreEqual(personForm.saveToolStripButton.Enabled, false, "Save button did not become disabled");
160 Assert.AreEqual(personForm.cancelToolStripButton.Enabled, true, "Cancel button is not enabled");
161 Assert.AreEqual(personForm.closeToolStripButton.Enabled, true, "Button state is not correct");
162 Assert.AreEqual(personForm.validateToolStripButton.Enabled, true, "Button state is not correct");
163
164 personForm.firstNameTextBox.Text = "ABC";
165
166 Assert.AreEqual(personForm.saveToolStripButton.Enabled, true, "Save button did not become enabled");
167 Assert.AreEqual(personForm.cancelToolStripButton.Enabled, true, "Cancel button is not enabled");
168 Assert.AreEqual(personForm.closeToolStripButton.Enabled, true, "Button state is not correct");
169 Assert.AreEqual(personForm.validateToolStripButton.Enabled, true, "Button state is not correct");
170 }
171 }
172
173 }
174}
Provides consistent context information between the client and server DataPortal objects.
void Clear()
Clears all context collections.
static EditablePerson NewEditablePerson()
static EditablePerson GetEditablePerson()