public async Task HttpPost_ConfirmRemoval_WithYesOptionSelected_AndRequestReturnsCacheInvalidation_ShouldInvalidateProducerSearch() { var viewModel = new ConfirmRemovalViewModel { SelectedValue = "Yes" }; A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <RemoveProducer> ._)) .Returns(new RemoveProducerResult(true)); await ProducersController().ConfirmRemoval(A.Dummy <Guid>(), viewModel); A.CallTo(() => cache.InvalidateProducerSearch()) .MustHaveHappened(Repeated.Exactly.Once); }
public async Task <ActionResult> ConfirmRemoval(Guid registeredProducerId, ConfirmRemovalViewModel model) { await SetBreadcrumb(); ProducerDetailsScheme producerDetailsScheme = await FetchProducerDetailsScheme(registeredProducerId); if (!ModelState.IsValid) { return(View(new ConfirmRemovalViewModel { Producer = producerDetailsScheme })); } if (model.SelectedValue == "Yes") { RemoveProducerResult result; using (IWeeeClient client = apiClient()) { result = await client.SendAsync(User.GetAccessToken(), new RemoveProducer(registeredProducerId)); } if (result.InvalidateProducerSearchCache) { await cache.InvalidateProducerSearch(); } return(RedirectToAction("Removed", new { producerDetailsScheme.RegistrationNumber, producerDetailsScheme.ComplianceYear, producerDetailsScheme.SchemeName })); } else { return(RedirectToAction("Details", new { producerDetailsScheme.RegistrationNumber })); } }
public async Task <ActionResult> Index(FormCollection form) { await cache.InvalidateProducerSearch(); return(View("CacheCleared")); }