public async Task DeleteReturnsTheCorrectViewModel()
        {
            var campaignSummaryViewModel = new CampaignSummaryViewModel {
                Id = 4, OrganizationId = 1, Name = "TestCampaign"
            };
            var deleteResourceQuery = new ResourceDeleteViewModel {
                Id = 1, CampaignId = 4
            };

            var mockMediator = new Mock <IMediator>();

            mockMediator.Setup(m => m.SendAsync(It.IsAny <DeleteResourceQuery>())).ReturnsAsync(deleteResourceQuery);
            mockMediator.Setup(m => m.SendAsync(It.IsAny <CampaignSummaryQuery>())).ReturnsAsync(campaignSummaryViewModel);

            var sut = new ResourceController(mockMediator.Object);

            sut.MakeUserAnOrgAdmin(campaignSummaryViewModel.OrganizationId.ToString());

            var result = await sut.Delete(It.IsAny <int>()) as ViewResult;

            result.ShouldNotBeNull();
            result.ShouldBeOfType <ViewResult>();
            result.Model.ShouldBeOfType <ResourceDeleteViewModel>();
            result.Model.ShouldBeSameAs(deleteResourceQuery);
        }
        public async Task DeleteGetReturnsUnauthorized_WhenCampaignIsNull()
        {
            var mockMediator = new Mock <IMediator>();

            mockMediator.Setup(m => m.SendAsync(It.IsAny <DeleteResourceQuery>())).ReturnsAsync(new ResourceDeleteViewModel());

            var sut = new ResourceController(mockMediator.Object);

            var result = await sut.Delete(It.IsAny <int>()) as UnauthorizedResult;

            result.ShouldNotBeNull();
            result.ShouldBeOfType <UnauthorizedResult>();
            result.StatusCode.ShouldBe((int)HttpStatusCode.Unauthorized);
        }
        public async Task DeleteGetReturnsUnauthorized_WhenUserIsNotOrganizationAdmin()
        {
            var campaignSummaryViewModel = new CampaignSummaryViewModel {
                Id = 4, OrganizationId = 1, Name = "TestCampaign"
            };

            var mockMediator = new Mock <IMediator>();

            mockMediator.Setup(m => m.SendAsync(It.IsAny <DeleteResourceQuery>())).ReturnsAsync(new ResourceDeleteViewModel());
            mockMediator.Setup(m => m.SendAsync(It.IsAny <CampaignSummaryQuery>())).ReturnsAsync(campaignSummaryViewModel);

            var sut = new ResourceController(mockMediator.Object);

            sut.MakeUserNotAnOrgAdmin();

            var result = await sut.Delete(It.IsAny <int>()) as UnauthorizedResult;

            result.ShouldNotBeNull();
            result.ShouldBeOfType <UnauthorizedResult>();
            result.StatusCode.ShouldBe((int)HttpStatusCode.Unauthorized);
        }
        public async Task DeleteGetSendsDeleteResourceQueryWithCorrectResourceId()
        {
            var deleteResourceQuery = new ResourceDeleteViewModel {
                Id = 1, CampaignId = 4
            };
            var campaignSummaryViewModel = new CampaignSummaryViewModel {
                Id = 4, OrganizationId = 1, Name = "TestCampaign"
            };

            var mockMediator = new Mock <IMediator>();

            mockMediator.Setup(m => m.SendAsync(It.IsAny <DeleteResourceQuery>())).ReturnsAsync(deleteResourceQuery);
            mockMediator.Setup(m => m.SendAsync(It.IsAny <CampaignSummaryQuery>())).ReturnsAsync(campaignSummaryViewModel);
            var sut = new ResourceController(mockMediator.Object);

            sut.MakeUserAnOrgAdmin(campaignSummaryViewModel.OrganizationId.ToString());

            var result = await sut.Delete(deleteResourceQuery.Id) as ViewResult;

            result.ShouldNotBeNull();
            mockMediator.Verify(m => m.SendAsync(It.Is <DeleteResourceQuery>(c => c.ResourceId == deleteResourceQuery.Id)), Times.Once);
        }