コード例 #1
0
        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);
        }
コード例 #2
0
        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>()));
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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>()));
        }
コード例 #5
0
        public void Details_Returns_ViewResult()
        {
            var result = testController.Details(1);

            Assert.IsType <ViewResult>(result);
        }