public async void GetConfirmRemoval_ReturnsHttpForbiddenResult_WhenCanRemoveProducerIsFalse()
        {
            // Arrange
            IWeeeClient weeeClient = A.Fake <IWeeeClient>();

            ProducersController controller = new ProducersController(
                A.Dummy <BreadcrumbService>(),
                A.Dummy <ISearcher <ProducerSearchResult> >(),
                () => weeeClient,
                A.Dummy <IWeeeCache>(),
                configurationService);

            A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetProducerDetailsByRegisteredProducerId> ._))
            .Returns(
                new ProducerDetailsScheme
            {
                CanRemoveProducer = false
            });

            // Act
            var result = await controller.ConfirmRemoval(A.Dummy <Guid>());

            // Assert
            Assert.IsType <HttpForbiddenResult>(result);
        }
        public async void GetConfirmRemoval_ReturnsConfirmRemovalView_WhenCanRemoveProducerIsTrue()
        {
            // Arrange
            IWeeeClient weeeClient = A.Fake <IWeeeClient>();

            ProducersController controller = new ProducersController(
                A.Dummy <BreadcrumbService>(),
                A.Dummy <ISearcher <ProducerSearchResult> >(),
                () => weeeClient,
                A.Dummy <IWeeeCache>(),
                configurationService);

            A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetProducerDetailsByRegisteredProducerId> ._))
            .Returns(
                new ProducerDetailsScheme
            {
                CanRemoveProducer = true
            });

            // Act
            ActionResult result = await controller.ConfirmRemoval(A.Dummy <Guid>());

            // Assert
            ViewResult viewResult = result as ViewResult;

            Assert.NotNull(viewResult);

            Assert.True(string.IsNullOrEmpty(viewResult.ViewName) || viewResult.ViewName.ToLowerInvariant() == "confirmremoval");
        }
        public async Task PostConfirmRemoval_WithInvalidModel_ReturnsConfirmRemovalView()
        {
            // Arrange
            ProducersController controller = new ProducersController(
                A.Dummy <BreadcrumbService>(),
                A.Dummy <ISearcher <ProducerSearchResult> >(),
                () => A.Dummy <IWeeeClient>(),
                A.Dummy <IWeeeCache>(),
                configurationService);

            controller.ModelState.AddModelError("SomeProperty", "Exception");

            // Act
            ActionResult result = await controller.ConfirmRemoval(A.Dummy <Guid>(), A.Dummy <ConfirmRemovalViewModel>());

            // Assert
            ViewResult viewResult = result as ViewResult;

            Assert.NotNull(viewResult);

            Assert.True(string.IsNullOrEmpty(viewResult.ViewName) || viewResult.ViewName.ToLowerInvariant() == "confirmremoval");
        }
        public async void GetConfirmRemoval_CallsApiForSpecifiedRegisteredProducer_AndPopulatesViewModel()
        {
            // Arrange
            Guid registeredProducerId = new Guid("9F253FE4-B644-4EA1-B58E-19C735512449");

            ProducerDetailsScheme producerDetailsScheme = new ProducerDetailsScheme
            {
                CanRemoveProducer = true
            };

            IWeeeClient weeeClient = A.Fake <IWeeeClient>();

            A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetProducerDetailsByRegisteredProducerId> ._))
            .WhenArgumentsMatch(a => a.Get <GetProducerDetailsByRegisteredProducerId>("request").RegisteredProducerId == registeredProducerId)
            .Returns(producerDetailsScheme);

            ProducersController controller = new ProducersController(
                A.Dummy <BreadcrumbService>(),
                A.Dummy <ISearcher <ProducerSearchResult> >(),
                () => weeeClient,
                A.Dummy <IWeeeCache>(),
                configurationService);

            // Act
            ActionResult result = await controller.ConfirmRemoval(registeredProducerId);

            // Assert
            ViewResult viewResult = result as ViewResult;

            Assert.NotNull(viewResult);

            ConfirmRemovalViewModel viewModel = viewResult.Model as ConfirmRemovalViewModel;

            Assert.NotNull(viewModel);

            Assert.Equal(producerDetailsScheme, viewModel.Producer);
        }