public async Task DeletePurchase_OutOfBounds() { // Arrange var repo = new FakePurchaseRepo(TestData.Purchases()); var productRepo = new FakeProductService(TestData.Products()); using (var controller = new PurchasesController(repo, productRepo, null, null)) { var purchaseId = -6; // Act var result = await controller.DeleteConfirmed(purchaseId); // Assert Assert.IsInstanceOfType(result, typeof(BadRequestResult)); } }
public async Task DeletePurchase_Success() { // Arrange var repo = new FakePurchaseRepo(TestData.Purchases()); var productRepo = new FakeProductService(TestData.Products()); using (var controller = new PurchasesController(repo, productRepo, null, null)) { var purchaseId = 1; // Act await controller.DeleteConfirmed(purchaseId); // Assert var purchase = await controller.Details(purchaseId); Assert.IsInstanceOfType(purchase.Result, typeof(NotFoundResult)); } }