public void IndexReturnsAView()
        {
            var sut    = new CampaignController(Mock.Of <IMediator>());
            var result = sut.Index();

            Assert.IsType <ViewResult>(result);
        }
        public void IndexReturnsAView()
        {
            var sut = new CampaignController(Mock.Of<IMediator>());
            var result = sut.Index();

            Assert.IsType<ViewResult>(result);
        }
        public void IndexSendsCampaignIndexQuery()
        {
            var mockMediator = new Mock<IMediator>();
            var sut = new CampaignController(mockMediator.Object);
            sut.Index();

            mockMediator.Verify(m => m.Send(It.IsAny<UnlockedCampaignsQuery>()), Times.Once);
        }
        public async Task IndexSendsCampaignIndexQuery()
        {
            var mockMediator = new Mock <IMediator>();
            var sut          = new CampaignController(mockMediator.Object);
            await sut.Index();

            mockMediator.Verify(m => m.SendAsync(It.IsAny <UnlockedCampaignsQuery>()), Times.Once);
        }
Esempio n. 5
0
        public async Task IndexReturnsAView()
        {
            var authorizationServiceMock = new Mock <IUserAuthorizationService>();

            authorizationServiceMock.Setup(a => a.IsCampaignManager()).ReturnsAsync(false);

            var sut    = new CampaignController(Mock.Of <IMediator>(), authorizationServiceMock.Object, null);
            var result = await sut.Index();

            Assert.IsType <ViewResult>(result);
        }
Esempio n. 6
0
        public async Task IndexSendsCampaignIndexQuery()
        {
            var mockMediator             = new Mock <IMediator>();
            var authorizationServiceMock = new Mock <IUserAuthorizationService>();

            authorizationServiceMock.Setup(a => a.IsCampaignManager()).ReturnsAsync(false);

            var sut = new CampaignController(mockMediator.Object, authorizationServiceMock.Object, null);
            await sut.Index();

            mockMediator.Verify(m => m.SendAsync(It.IsAny <UnlockedCampaignsQuery>()), Times.Once);
        }
Esempio n. 7
0
        public async Task IndexReturnsUnlockedCampaignsWithTrueValueForIsCampaignManager()
        {
            var mockedMediator = new Mock <IMediator>();

            mockedMediator.Setup(m => m.SendAsync(It.IsAny <UnlockedCampaignsQuery>())).ReturnsAsync(new List <CampaignViewModel> {
                new CampaignViewModel {
                    Id = 1
                }
            });

            var userAuthorizationMock = new Mock <IUserAuthorizationService>();

            userAuthorizationMock.Setup(u => u.IsCampaignManager()).ReturnsAsync(true);
            var sut = new CampaignController(mockedMediator.Object, userAuthorizationMock.Object, null);

            var result = await sut.Index() as ViewResult;

            var model = result.ViewData.Model as List <CampaignViewModel>;

            model.Any(m => m.IsCampaignManager).ShouldBeTrue();
        }