public async Task Post_with_unknown_postcode_redirects_to_region() { const string nextUri = "xxxxx region xxxxx"; _modelSaver .Save(_startSwitch) .Returns(new Response(new ResourceBuilder().WithLink("/rels/next /rels/domestic/region", nextUri).Build())); var viewModel = new StartSwitchViewModel(); var result = (RedirectToActionResult)await _controller.Index(viewModel); Assert.That(result.ActionName, Is.EqualTo("Index").IgnoreCase); Assert.That(result.ControllerName, Is.EqualTo("Region").IgnoreCase); Assert.That(result.RouteValues["uri"], Is.EqualTo(nextUri)); }
public async Task Post_with_missing_postcode_returns_errors() { _modelSaver .Save(_startSwitch) .Returns(new Response(new ResourceBuilder().WithError("some-error").Build())); var requestViewModel = new StartSwitchViewModel(); var result = (ViewResult)await _controller.Index(requestViewModel); var responseViewModel = (StartSwitchViewModel)result.Model; var error = responseViewModel.Errors.Single(); Assert.That(error, Is.EqualTo("some-error")); }
public async Task Post_updates_the_postcode_in_start_switch_model() { const string postcode = "post-code"; _modelSaver .Save(_startSwitch) .Returns(new Response(new ResourceBuilder().WithLink("/rels/next", "next-uri").Build())); var viewModel = new StartSwitchViewModel { Postcode = postcode }; await _controller.Index(viewModel); Assert.That(_startSwitchResource.DataTemplate.GetItem("supplyPostcode", "postcode").Data, Is.EqualTo("post-code")); }
public async Task Post_with_known_postcode_redirects_to_current_supply() { const string postcode = "post-code"; _modelSaver .Save(_startSwitch) .Returns(new Response(new ResourceBuilder().WithLink("/rels/next", "next-uri").Build())); var viewModel = new StartSwitchViewModel { Postcode = postcode }; var result = (RedirectToActionResult)await _controller.Index(viewModel); Assert.That(result.ActionName, Is.EqualTo("index").IgnoreCase); Assert.That(result.ControllerName, Is.EqualTo("currentSupply").IgnoreCase); Assert.That(result.RouteValues["uri"], Is.EqualTo("next-uri")); }