示例#1
0
        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;
        }
示例#2
0
        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();
        }