public async Task <ActionResult> Removed(RemovedViewModel model) { using (IWeeeClient client = apiClient()) { var isAssociatedWithAnotherScheme = await client.SendAsync(User.GetAccessToken(), new IsProducerRegisteredForComplianceYear(model.RegistrationNumber, model.ComplianceYear)); if (isAssociatedWithAnotherScheme) { return(RedirectToAction("Details", new { model.RegistrationNumber })); } return(RedirectToAction("Search")); } }
public async void HttpPost_RemovedProducer_ProducerNotAssociatedWithOtherScheme_ShouldRedirectToSearchAction() { // Arrange A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <IsProducerRegisteredForComplianceYear> ._)) .Returns(false); // Act var model = new RemovedViewModel { RegistrationNumber = "ABC12345" }; var result = await ProducersController().Removed(model); // Assert A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <IsProducerRegisteredForComplianceYear> ._)) .MustHaveHappened(); Assert.IsType <RedirectToRouteResult>(result); var routeValues = ((RedirectToRouteResult)result).RouteValues; Assert.Equal("Search", routeValues["action"]); }