Exemple #1
0
        public void ServiceCallSucceeded()
        {
            var continueWith = 0;

            _serviceCall.ContinueWith(serviceCall =>
            {
                Assert.AreEqual(_serviceCall, serviceCall);
                Assert.IsTrue(serviceCall.IsCompleted);
                continueWith++;
            });
            Assert.AreEqual(0, continueWith);
            _serviceCall.SetResult("Test");
            Assert.AreEqual(1, continueWith);
            Assert.IsTrue(_serviceCall.IsCompleted);
            Assert.IsFalse(_serviceCall.IsCanceled);
            Assert.IsFalse(_serviceCall.IsFaulted);
            Assert.AreEqual("Test", _serviceCall.Result);
            Assert.IsNull(_serviceCall.Exception);

            // Check copy state.
            var copy = new ServiceCall();

            copy.CopyState(_serviceCall);
            Assert.IsTrue(copy.IsCompleted);
            Assert.IsFalse(copy.IsCanceled);
            Assert.IsFalse(copy.IsFaulted);
            Assert.AreEqual("Test", copy.Result);
            Assert.IsNull(copy.Exception);
        }