12using System.Security.Claims;
17using TestClass = NUnit.Framework.TestFixtureAttribute;
18using TestInitialize = NUnit.Framework.SetUpAttribute;
19using TestCleanup = NUnit.Framework.TearDownAttribute;
20using TestMethod = NUnit.Framework.TestAttribute;
21using TestSetup = NUnit.Framework.SetUpAttribute;
23using Microsoft.VisualStudio.TestTools.UnitTesting;
32 private static ClaimsPrincipal GetPrincipal(params
string[] roles)
34 var identity =
new ClaimsIdentity();
35 foreach (var item
in roles)
36 identity.AddClaim(
new Claim(ClaimTypes.Role, item));
37 return new ClaimsPrincipal(identity);
45 _testDIContext = TestDIContextFactory.CreateDefaultContext();
51 TestDIContext testDIContext = TestDIContextFactory.CreateContext(GetPrincipal(
"Admin"));
55 bool propertyChangedFired =
false;
57 testObj.PropertyChanged += (o, e) =>
59 propertyChangedFired =
true;
63 context.Assert.AreEqual(
false, propertyChangedFired);
64 context.Assert.AreEqual(
false, testObj.IsDirty);
68 context.Assert.AreEqual(
false, propertyChangedFired);
69 context.Assert.AreEqual(
false, testObj.IsDirty);
72 context.Assert.AreEqual(
true, propertyChangedFired);
73 context.Assert.AreEqual(2, testObj.
ReadId());
74 context.Assert.AreEqual(
true, testObj.IsDirty);
76 context.Assert.Success();
84 TestDIContext testDIContext = TestDIContextFactory.CreateContext(GetPrincipal(
"Admin"));
88 bool propertyChangedFired =
false;
91 testObj.PropertyChanged += (o, e) =>
93 propertyChangedFired =
true;
97 context.Assert.AreEqual(
false, propertyChangedFired);
98 context.Assert.AreEqual(
false, testObj.IsDirty);
101 context.Assert.AreEqual(
true, testObj.IsDirty);
102 context.Assert.Success();
110 TestDIContext testDIContext = TestDIContextFactory.CreateContext(GetPrincipal(
"Admin"));
114 bool propertyChangedFired =
false;
117 testObj.PropertyChanged += (o, e) =>
119 propertyChangedFired =
true;
123 context.Assert.AreEqual(
false, propertyChangedFired);
124 context.Assert.AreEqual(
false, testObj.IsDirty);
125 context.Assert.Success();
132 TestDIContext customDIContext = TestDIContextFactory.CreateContext(GetPrincipal(
"Admin"));
136 bool propertyChangedFired =
false;
138 testObj.PropertyChanged += (o, e) =>
140 propertyChangedFired =
true;
143 context.Assert.AreEqual(1, testObj.
ReadId());
144 context.Assert.AreEqual(
true, propertyChangedFired);
145 context.Assert.AreEqual(
true, testObj.IsDirty);
146 context.Assert.Success();
154 TestDIContext testDIContext = TestDIContextFactory.CreateContext(GetPrincipal(
"Admin"));
159 bool propertyChangedFired =
false;
160 testObj.PropertyChanged += (o, e) =>
162 propertyChangedFired =
true;
166 context.Assert.AreEqual(
true, propertyChangedFired);
167 context.Assert.AreEqual(
true, testObj.IsDirty);
168 context.Assert.Success();
175 TestDIContext testDIContext = TestDIContextFactory.CreateContext(GetPrincipal(
"Admin"));
179 bool propertyChangedFired =
false;
181 testObj.PropertyChanged += (o, e) =>
183 propertyChangedFired =
true;
186 context.Assert.AreEqual(
false, testObj.IsDirty);
188 context.Assert.AreEqual(0, testObj.
ReadId2());
189 context.Assert.AreEqual(
false, propertyChangedFired);
190 context.Assert.Success();
199 TestDIContext testDIContext = TestDIContextFactory.CreateContext(GetPrincipal(
"Admin"));
203 bool propertyChangedFired =
false;
206 testObj.PropertyChanged += (o, e) =>
208 propertyChangedFired =
true;
211 context.Assert.AreEqual(
false, testObj.IsDirty);
213 context.Assert.AreEqual(
false, propertyChangedFired);
214 context.Assert.Success();
221 TestDIContext testDIContext = TestDIContextFactory.CreateContext(GetPrincipal(
"Admin"));
225 bool propertyChangedFired =
false;
227 testObj.PropertyChanged += (o, e) =>
229 propertyChangedFired =
true;
232 context.Assert.AreEqual(
true, testObj.IsDirty);
233 context.Assert.AreEqual(1, testObj.
ReadId3());
234 context.Assert.AreEqual(
true, propertyChangedFired);
235 context.Assert.Success();
243 TestDIContext testDIContext = TestDIContextFactory.CreateContext(GetPrincipal(
"Admin"));
248 bool propertyChangedFired =
false;
249 testObj.PropertyChanged += (o, e) =>
251 propertyChangedFired =
true;
254 context.Assert.AreEqual(
true, testObj.IsDirty);
256 context.Assert.AreEqual(
true, propertyChangedFired);
257 context.Assert.Success();
264 TestDIContext testDIContext = TestDIContextFactory.CreateContext(GetPrincipal(
"Admin"));
268 bool propertyChangedFired =
false;
270 testObj.PropertyChanged += (o, e) =>
272 propertyChangedFired =
true;
275 context.Assert.AreEqual(
false, testObj.IsDirty);
277 context.Assert.AreEqual(0, testObj.
ReadId4());
278 context.Assert.AreEqual(
false, propertyChangedFired);
279 context.Assert.Success();
286 TestDIContext testDIContext = TestDIContextFactory.CreateContext(GetPrincipal(
"Admin"));
292 context.Assert.AreEqual(
false, obj.IsDirty);
294 context.Assert.Success();
void LoadId2ByPass(int id)
void LoadIdByNestedPass(int id)
void LoadId4ByPass(int id)
void LoadIdByPass(int id)
static BypassBusinessBaseUsingFactory GetObject(IDataPortal< BypassBusinessBaseUsingFactory > dataPortal)
void TestBypassReadWriteNoRightsBackingField()
void TestBypassWriteNoRightsDoNotBypassBackingField()
void TestBypassReadWriteNoRightsTurnNotificationBackOn()
void TestBypassReadWriteNoRights()
void TestBypassReadWriteWithRights()
void TestBypassWriteNoRightsDoNotBypass()
void TestBypassReadNoRightsDoNotBypassBackingField()
void TestBypassReadWriteWithRightsTurnNotificationBackOn()
void TestBypassReadWriteWithRightsBackingField()
static void ClassInitialize(TestContext context)
void TestBypassReadNoRightsDoNotBypass()
Type to carry context information for DI in unit tests
UnitTestContext GetContext()
Interface defining the members of the data portal type.
object Fetch(params object[] criteria)
Called by a factory method in a business class to retrieve an object, which is loaded with values fro...