public async Task SegmentControllerDocumentHtmlReturnsNoContentWhenNoData(string mediaTypeName) { // Arrange var controller = BuildSegmentController(mediaTypeName); A.CallTo(() => FakeHowToBecomeSegmentService.GetByNameAsync(A <string> .Ignored)).Returns((HowToBecomeSegmentModel)null); // Act var result = await controller.Document(Article).ConfigureAwait(false); // Assert A.CallTo(() => FakeHowToBecomeSegmentService.GetByNameAsync(A <string> .Ignored)).MustHaveHappenedOnceExactly(); var statusResult = Assert.IsType <NoContentResult>(result); Assert.Equal((int)HttpStatusCode.NoContent, statusResult.StatusCode); controller.Dispose(); }
public async Task SegmentControllerDocumentHtmlReturnsSuccess(string mediaTypeName) { // Arrange var expectedResult = A.Fake <HowToBecomeSegmentModel>(); var controller = BuildSegmentController(mediaTypeName); A.CallTo(() => FakeHowToBecomeSegmentService.GetByNameAsync(A <string> .Ignored)).Returns(expectedResult); A.CallTo(() => FakeMapper.Map <DocumentViewModel>(A <HowToBecomeSegmentModel> .Ignored)).Returns(A.Fake <DocumentViewModel>()); // Act var result = await controller.Document(Article).ConfigureAwait(false); // Assert A.CallTo(() => FakeHowToBecomeSegmentService.GetByNameAsync(A <string> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => FakeMapper.Map <DocumentViewModel>(A <HowToBecomeSegmentModel> .Ignored)).MustHaveHappenedOnceExactly(); var viewResult = Assert.IsType <ViewResult>(result); Assert.IsAssignableFrom <DocumentViewModel>(viewResult.ViewData.Model); controller.Dispose(); }