public async Task TestAsyncAwaitRule() { var har = new AsyncRuleRoot(); var tcs = new TaskCompletionSource <bool>(); har.ValidationComplete += (o, e) => { Assert.AreEqual("abc", har.AsyncAwait, "ends with value"); tcs.SetResult(true); }; har.AsyncAwait = "123456"; await tcs.Task; }
public void TestAsyncRulesAndSyncRulesValid() { UnitTestContext context = GetContext(); var har = new AsyncRuleRoot(); context.Assert.IsTrue(string.IsNullOrEmpty(har.CustomerNumber)); context.Assert.IsTrue(string.IsNullOrEmpty(har.CustomerName)); context.Assert.IsFalse(har.IsValid, "IsValid 1"); har.ValidationComplete += (o, e) => { context.Assert.IsFalse(string.IsNullOrEmpty(har.CustomerNumber)); context.Assert.IsFalse(string.IsNullOrEmpty(har.CustomerName)); context.Assert.IsTrue(har.IsValid, "IsValid 2"); context.Assert.Success(); }; har.CustomerNumber = "123456"; context.Complete(); }