Delete() public method

public Delete ( int id ) : Task
id int
return Task
        public async Task DeleteReturnsCorrectViewModelWhenUserIsOrgAdmin()
        {
            const int organizationId = 99;
            const int campaignId = 100;

            var mockMediator = new Mock<IMediator>();
            mockMediator.Setup(mock => mock.SendAsync(It.Is<CampaignSummaryQuery>(c => c.CampaignId == campaignId))).ReturnsAsync(new CampaignSummaryViewModel { Id = campaignId, OrganizationId = organizationId });

            var controller = new CampaignController(mockMediator.Object, null);
            controller.MakeUserAnOrgAdmin(organizationId.ToString());

            var view = (ViewResult)await controller.Delete(campaignId);
            var viewModel = (CampaignSummaryViewModel)view.ViewData.Model;

            Assert.Equal(viewModel.Id, campaignId);
        }
 public async Task DeleteSendsCampaignSummaryQueryWithCorrectCampaignId()
 {
     var ORGANIZATION_ID = 99;
     var CAMPAIGN_ID = 100;
     var mockMediator = new Mock<IMediator>();
     mockMediator.Setup(mock => mock.SendAsync(It.Is<CampaignSummaryQuery>(c => c.CampaignId == CAMPAIGN_ID))).ReturnsAsync(new CampaignSummaryViewModel { Id = CAMPAIGN_ID, OrganizationId = ORGANIZATION_ID });
     var controller = new CampaignController(mockMediator.Object, null);
     controller.SetClaims(new List<Claim>
     {
         new Claim(AllReady.Security.ClaimTypes.UserType, UserType.OrgAdmin.ToString()),
         new Claim(AllReady.Security.ClaimTypes.Organization, ORGANIZATION_ID.ToString())
     });
     var view = (ViewResult)(await controller.Delete(CAMPAIGN_ID));
     mockMediator.Verify(mock => mock.SendAsync(It.Is<CampaignSummaryQuery>(c => c.CampaignId == CAMPAIGN_ID)), Times.Once);
 }
        public async Task DeleteReturnsCorrectViewWhenUserIsOrgAdmin()
        {
            const int organizationId = 1;

            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.SendAsync(It.IsAny<DeleteViewModelQuery>())).ReturnsAsync(new DeleteViewModel { OrganizationId = organizationId });

            var sut = new CampaignController(mediator.Object, null);
            sut.MakeUserAnOrgAdmin(organizationId.ToString());

            Assert.IsType<ViewResult>(await sut.Delete(It.IsAny<int>()));
        }
        public async Task DeleteReturnsHttpUnauthorizedResultWhenUserIsNotOrgAdmin()
        {
            var mediator = new Mock<IMediator>();
            mediator.Setup(x => x.SendAsync(It.IsAny<DeleteViewModelQuery>())).ReturnsAsync(new DeleteViewModel());

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

            Assert.IsType<UnauthorizedResult>(await sut.Delete(It.IsAny<int>()));
        }
        public async Task DeleteSendsDeleteQueryWithCorrectCampaignId()
        {
            const int organizationId = 99;
            const int campaignId = 100;

            var mockMediator = new Mock<IMediator>();
            mockMediator.Setup(mock => mock.SendAsync(It.Is<DeleteViewModelQuery>(c => c.CampaignId == campaignId))).ReturnsAsync(new DeleteViewModel { Id = campaignId, OrganizationId = organizationId });

            var sut = new CampaignController(mockMediator.Object, null);
            sut.MakeUserAnOrgAdmin(organizationId.ToString());
            await sut.Delete(campaignId);

            mockMediator.Verify(mock => mock.SendAsync(It.Is<DeleteViewModelQuery>(c => c.CampaignId == campaignId)), Times.Once);
        }
 public async Task DeleteReturnsCorrectViewModelWhenUserIsOrgAdmin()
 {
     int ORGANIZATION_ID = 99;
     int CAMPAIGN_ID = 100;
     var mockMediator = new Mock<IMediator>();
     mockMediator.Setup(mock => mock.SendAsync(It.Is<CampaignSummaryQuery>(c => c.CampaignId == CAMPAIGN_ID))).ReturnsAsync(new CampaignSummaryModel { Id = CAMPAIGN_ID, OrganizationId = ORGANIZATION_ID });
     CampaignController controller = new CampaignController(mockMediator.Object, null);
     controller.SetClaims(new List<Claim>
     {
         new Claim(AllReady.Security.ClaimTypes.UserType, UserType.OrgAdmin.ToString()),
         new Claim(AllReady.Security.ClaimTypes.Organization, ORGANIZATION_ID.ToString())
     });
     ViewResult view = (ViewResult)(await controller.Delete(CAMPAIGN_ID));
     CampaignSummaryModel viewModel = (CampaignSummaryModel)view.ViewData.Model;
     Assert.Equal(viewModel.Id, CAMPAIGN_ID);
 }