Exemplo n.º 1
0
        public async Task LockUnlockSendsLockUnlockCampaignCommandWithCorrectCampaignIdWhenUserIsSiteAdmin()
        {
            const int campaignId   = 99;
            var       mockMediator = new Mock <IMediator>();

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

            sut.MakeUserASiteAdmin();

            await sut.LockUnlock(campaignId);

            mockMediator.Verify(mock => mock.SendAsync(It.Is <LockUnlockCampaignCommand>(q => q.CampaignId == campaignId)), Times.Once);
        }
Exemplo n.º 2
0
        public async Task LockUnlockRedirectsToCorrectActionWithCorrectRouteValuesWhenUserIsSiteAdmin()
        {
            const int campaignId   = 100;
            var       mockMediator = new Mock <IMediator>();

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

            sut.MakeUserASiteAdmin();

            var view = (RedirectToActionResult)await sut.LockUnlock(campaignId);

            // verify the next route
            Assert.Equal(nameof(CampaignController.Details), view.ActionName);
            Assert.Equal("Admin", view.RouteValues["area"]);
            Assert.Equal(view.RouteValues["id"], campaignId);
        }