public void ShouldDeleteCustomerAndRedirectToIndex() { ICustomerAdapter adapter = Substitute.For <ICustomerAdapter>(); using (ClassicController controller = new ClassicController(adapter)) { CustomerData data = new CustomerData() { CustomerId = Guid.NewGuid().ToString("N") }; ActionResult result = controller.Delete(data); adapter.Received().RemoveCustomer(data.CustomerId); ActionResultHelper.AssertRedirected(result, controller.Name, controller.ActionNames.Index); } }
public void ShouldRetrieveCustomerForDelete() { ICustomerAdapter adapter = Substitute.For <ICustomerAdapter>(); CustomerData data = new CustomerData(); adapter.GetCustomer(Arg.Any <string>()).Returns(data); using (ClassicController controller = new ClassicController(adapter)) { string customerId = Guid.NewGuid().ToString("N"); ActionResult result = controller.Delete(customerId); CustomerData model = ActionResultHelper.AssertViewWithModel <CustomerData>(result, controller.Views.Delete); adapter.Received().GetCustomer(customerId); Assert.AreSame(data, model, "The customer data was not passed to the view."); } }