public async Task Details_WhenIdIsNotNullAndConferenceFound_ShouldReturnConferenceDetailsView() { // Arrange var conferencesIndexViewModel = A.Fake <IConferencesIndexViewModel>(); var conferencesDetailsViewModel = A.Fake <IConferencesDetailsViewModel>(); var conferenceRepository = A.Fake <IConferenceRepository>(); Conference?conference = new Conference(); A.CallTo(() => conferenceRepository.GetConferenceAsync(A <int> .Ignored)).Returns(conference); var sharedRepository = A.Fake <ISharedRepository>(); var testController = new ConferencesController(conferencesIndexViewModel, conferencesDetailsViewModel, conferenceRepository, sharedRepository); int?id = 0; // Act var result = await testController.Details(id); // Assert A.CallTo(() => conferenceRepository.GetConferenceAsync(id.Value)).MustHaveHappenedOnceExactly(); conferencesDetailsViewModel.Conference.ShouldBe(conference); result.ShouldBeOfType <ViewResult>(); ((ViewResult)result).Model.ShouldBe(conferencesDetailsViewModel); }
public async Task Details_WhenIdIsNull_ShouldReturnNotFound() { // Arrange var conferencesIndexViewModel = A.Fake <IConferencesIndexViewModel>(); var conferencesDetailsViewModel = A.Fake <IConferencesDetailsViewModel>(); var conferenceRepository = A.Fake <IConferenceRepository>(); var sharedRepository = A.Fake <ISharedRepository>(); var testController = new ConferencesController(conferencesIndexViewModel, conferencesDetailsViewModel, conferenceRepository, sharedRepository); int?id = null; // Act var result = await testController.Details(id); // Assert result.ShouldBeOfType <NotFoundResult>(); }