Esempio n. 1
0
        public async Task Post_with_any_errors_returns_errors()
        {
            _futureSupplyResourceBuilder
            .WithDataTemplate()
            .WithGroup("futureSupply")
            .WithItem("id")
            .WithError("some-future-supply-error");

            _futureSuppliesResourceBuilder.WithResult(new Result
            {
                SupplyType = new SupplyType
                {
                    Id = "4"
                },
                EnergySupplies = new EnergySupply[] { }
            });

            StubFutureSupply();
            StubFutureSupplies();

            _modelSaver
            .Save(_futureSupplyModel)
            .Returns(new Response(_futureSupplyResource));

            var requestViewModel = new FutureSupplyViewModel {
                FutureSupplyUri = _uri, FutureTariffId = "the tariff id"
            };
            var result = (ViewResult)await _sut.Index(requestViewModel);

            var responseViewModel = (FutureSupplyViewModel)result.Model;

            var error = responseViewModel.Errors.Single();

            Assert.That(error, Is.EqualTo("some-future-supply-error"));
        }
Esempio n. 2
0
        public async Task Redirects_to_prepare_to_transfer_when_post_to_future_supply()
        {
            _futureSupplyResourceBuilder
            .WithDataTemplate()
            .WithGroup("futureSupply")
            .WithItem("id");
            StubFutureSupply();

            var nextResource = new ResourceBuilder()
                               .WithLink("/rels/next", "next-url")
                               .Build();

            _modelSaver.Save(_futureSupplyModel).Returns(new Response(nextResource));

            var viewModel = new FutureSupplyViewModel
            {
                FutureSupplyUri = _uri,
                FutureTariffId  = "the tariff id"
            };

            var result = (RedirectToActionResult)await _sut.Index(viewModel);

            Assert.That(result.ActionName, Is.EqualTo("Index"));
            Assert.That(result.ControllerName, Is.EqualTo("PrepareForTransfer"));
            Assert.That(result.RouteValues["uri"], Is.EqualTo("next-url"));
        }