コード例 #1
0
        public void DefaultStubBehavior_TaskOfObjectReturnType_ReturnsNullTask()
        {
            var stub = new StubIService() as IService;
            var task = stub.ReturnObjectAsync();

            Assert.IsNull(task);
        }
コード例 #2
0
        public void AsyncStubBehavior_TaskReturnType_ReturnsCompletedTask()
        {
            var stub = new StubIService {
                InstanceBehavior = new AsyncAwareDefaultValueStubBehavior()
            } as IService;
            var task = stub.ReturnNothingAsync();

            Assert.IsNotNull(task);
            Assert.IsTrue(task.IsCompleted && !task.IsFaulted && !task.IsCanceled);
        }
コード例 #3
0
        public void AsyncStubBehavior_TaskOfBoolReturnType_ReturnsCompletedTask()
        {
            var stub = new StubIService {
                InstanceBehavior = new AsyncAwareDefaultValueStubBehavior()
            } as IService;
            var task = stub.ReturnBoolAsync();

            Assert.IsNotNull(task);
            Assert.IsTrue(task.IsCompleted && !task.IsFaulted && !task.IsCanceled);
            Assert.AreEqual(false, task.Result);
        }
コード例 #4
0
        public void AsyncStubBehavior_TaskOfTaskOfIntReturnType_ReturnsCompletedTasks()
        {
            var stub = new StubIService {
                InstanceBehavior = new AsyncAwareDefaultValueStubBehavior()
            } as IService;
            var task = stub.ReturnTaskOfIntAsync();

            Assert.IsNotNull(task);
            Assert.IsTrue(task.IsCompleted && !task.IsFaulted && !task.IsCanceled);
            var innerTask = task.Result;

            Assert.IsNotNull(innerTask);
            Assert.IsTrue(innerTask.IsCompleted && !innerTask.IsFaulted && !innerTask.IsCanceled);
            Assert.AreEqual(0, innerTask.Result);
        }
コード例 #5
0
 public void Setup()
 {
     _service = new StubIService();
     _service.GetData(number => _data.Take(number).ToList());
 }