public async Task DetailsReturnsCorrectViewAndViewModelWhenEventIsNotNullAndUserIsOrgAdmin() { const int orgId = 1; var viewModel = new ItineraryDetailsViewModel { OrganizationId = orgId }; var mediator = new Mock <IMediator>(); mediator.Setup(x => x.SendAsync(It.IsAny <ItineraryDetailQuery>())).ReturnsAsync(viewModel); var sut = new ItineraryController(mediator.Object, null); sut.MakeUserAnOrgAdmin(orgId.ToString()); var result = await sut.Details(It.IsAny <int>()) as ViewResult; Assert.Equal(result.ViewName, "Details"); var resultViewModel = result.ViewData.Model; Assert.IsType <ItineraryDetailsViewModel>(resultViewModel); Assert.Equal(resultViewModel, viewModel); }
public async Task DetailsReturnsHttpNotFoundResultWhenEventIsNull() { var mockMediator = new Mock <IMediator>(); mockMediator.Setup(mock => mock.SendAsync(It.IsAny <ItineraryDetailQuery>())).ReturnsAsync(null).Verifiable(); var controller = new ItineraryController(mockMediator.Object, null); Assert.IsType <NotFoundResult>(await controller.Details(It.IsAny <int>())); }
public async Task DetailsSendsEventDetailQueryAsyncWithCorrectEventId() { var mockMediator = new Mock <IMediator>(); mockMediator.Setup(mock => mock.SendAsync(It.IsAny <ItineraryDetailQuery>())).ReturnsAsync(null).Verifiable(); var sut = new ItineraryController(mockMediator.Object, MockSuccessValidation().Object); await sut.Details(1); mockMediator.Verify(x => x.SendAsync(It.IsAny <ItineraryDetailQuery>()), Times.Once); }
public async Task DetailsReturnsHttpUnauthorizedResultWhenUserIsNotOrgAdmin() { var mediator = new Mock <IMediator>(); mediator.Setup(x => x.SendAsync(It.IsAny <ItineraryDetailQuery>())).ReturnsAsync(new ItineraryDetailsViewModel()); var sut = new ItineraryController(mediator.Object, null); sut.MakeUserNotAnOrgAdmin(); Assert.IsType <UnauthorizedResult>(await sut.Details(It.IsAny <int>())); }
public void Details_Returns_ViewResult() { var result = testController.Details(1); Assert.IsType <ViewResult>(result); }