Beispiel #1
0
        public void TestInvalidation()
        {
            var component = new TestComponent();

            var task1 = component.Result.Task;

            var result1 = "value1";

            component.CompleteTest(result1);

            Assert.IsTrue(task1.IsCompleted, "completed 1");
            Assert.AreEqual(result1, task1.Result);

            var task2 = component.Result.Task;

            Assert.IsTrue(task2.IsCompleted, "completed 2");
            Assert.AreEqual(result1, task2.Result);

            component.Invalidate();

            var task3 = component.Result.Task;

            Assert.IsFalse(task3.IsCanceled, "task3.IsCanceled before .CompleteTest()");
            Assert.IsFalse(task3.IsCompleted, "task3.IsCompleted before .CompleteTest()");

            var result2 = "value1";

            component.CompleteTest(result1);

            Assert.IsFalse(task3.IsCanceled, "task3.IsCanceled after .CompleteTest()");
            Assert.IsTrue(task3.IsCompleted, "task3.IsCompleted after .CompleteTest()");

            Assert.AreEqual(result2, task3.Result);
        }