public async Task NoGreetingsShouldReturnNoContentAsyncTest() { var action = A.Fake<IGetLastTenGreetingsAction>(); A.CallTo(() => action.ExecuteAsync()).Returns(new SavedGreeting[0]); var actionFactory = A.Fake<IActionFactory>(); A.CallTo(() => actionFactory.CreateGetLastTenGreetingsAction()).Returns(action); var sut = new HelloWorldController(actionFactory); var response = await sut.GetLastTenGreetingsAsync(); response.Should().NotBeNull(); var okResponse = response.As<NoContentResult>(); okResponse.Should().NotBeNull(); }
public async Task SomeGreetingsShouldReturnGreetingsAsyncTest() { var action = A.Fake<IGetLastTenGreetingsAction>(); A.CallTo(() => action.ExecuteAsync()).Returns(new []{new SavedGreeting{Greeting = "mygreeting"}}); var actionFactory = A.Fake<IActionFactory>(); A.CallTo(() => actionFactory.CreateGetLastTenGreetingsAction()).Returns(action); var sut = new HelloWorldController(actionFactory); var response = await sut.GetLastTenGreetingsAsync(); var okResponse = response.As<OkObjectResult>(); okResponse.Should().NotBeNull(); okResponse.StatusCode.Should().Be((int)HttpStatusCode.OK); var content = okResponse.Value.As<SavedGreeting[]>(); content.Should().NotBeNull(); content[0].Greeting.Should().Be("mygreeting"); }