public void DefaultStubBehavior_TaskOfObjectReturnType_ReturnsNullTask() { var stub = new StubIService() as IService; var task = stub.ReturnObjectAsync(); Assert.IsNull(task); }
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); }
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); }
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); }
public void Setup() { _service = new StubIService(); _service.GetData(number => _data.Take(number).ToList()); }