9using System.Collections.Generic;
12using System.Threading;
14using System.Threading.Tasks;
19using TestClass = NUnit.Framework.TestFixtureAttribute;
20using TestInitialize = NUnit.Framework.SetUpAttribute;
21using TestCleanup = NUnit.Framework.TearDownAttribute;
22using TestMethod = NUnit.Framework.TestAttribute;
24using Microsoft.VisualStudio.TestTools.UnitTesting;
30 [System.Diagnostics.DebuggerStepThrough]
40 _testDIContext = TestDIContextFactory.CreateDefaultContext();
51 context.Assert.IsTrue(har.IsValid,
"IsValid 1");
53 har.ValidationComplete += (o, e) =>
55 context.Assert.IsTrue(har.IsValid,
"IsValid 2");
56 context.Assert.Success();
70 context.Assert.IsTrue(har.IsValid,
"IsValid 1");
72 har.ValidationComplete += (o, e) =>
74 context.Assert.IsFalse(har.IsValid,
"IsValid 2");
75 context.Assert.AreEqual(1, har.BrokenRulesCollection.Count);
76 context.Assert.Success();
90 var root = dataPortal.
Create();
91 root.ValidationComplete += (o, e) =>
94 context.
Assert.AreEqual(1, root.GetBrokenRules().Count);
95 context.
Assert.AreEqual(
"Operation is not valid due to the current state of the object.", root.GetBrokenRules()[0].Description);
112 for (
int x = 0; x < iterations; x++)
115 har.ValidationComplete += (o, e) =>
118 context.
Assert.AreEqual(1, har.BrokenRulesCollection.Count);
119 System.Diagnostics.Debug.WriteLine(har.BrokenRulesCollection.Count);
121 if (completed == iterations)
143 var har = dataPortal.
Create();
144 context.Assert.IsTrue(
string.IsNullOrEmpty(har.CustomerNumber));
145 context.Assert.IsTrue(
string.IsNullOrEmpty(har.CustomerName));
146 context.Assert.IsFalse(har.IsValid,
"IsValid 1");
149 har.ValidationComplete += (o, e) =>
151 context.Assert.IsFalse(
string.IsNullOrEmpty(har.CustomerNumber));
152 context.Assert.IsFalse(
string.IsNullOrEmpty(har.CustomerName));
154 context.Assert.IsTrue(har.IsValid,
"IsValid 2");
155 context.Assert.Success();
157 har.CustomerNumber =
"123456";
167 var har = dataPortal.
Create();
168 var tcs =
new TaskCompletionSource<bool>();
169 har.ValidationComplete += (o, e) =>
171 Assert.AreEqual(
"abc", har.AsyncAwait,
"ends with value");
174 har.AsyncAwait =
"123456";
Static dictionary-like class that offers similar functionality to GlobalContext This is used in tests...
static void Reinitialise()
Reinitialise the dictionary, clearing any existing results, ready for the next test
void TestAsyncRulesValid()
void ValidateMultipleObjectsSimultaneously()
void TestAsyncRuleError()
static void ClassInitialize(TestContext context)
async Task TestAsyncAwaitRule()
void TestAsyncRulesAndSyncRulesValid()
Type to carry context information for DI in unit tests
void IsFalse(bool condition)
UnitTestContext GetContext()
Interface defining the members of the data portal type.
object Create(params object[] criteria)
Called by a factory method in a business class to create a new object, which is loaded with default v...