public void InventoryAccessor_CancelOrder_ForExistingOrder_ShouldSucceed() { // Arrange using var inventoryDbContext = InventoryDbContext; try { const int orderId = 2; // Insert seed data into the database using one instance of the context AddCustomers(inventoryDbContext); AddOrders(inventoryDbContext); var inventoryAccessor = new InventoryAccessor(inventoryDbContext, Mapper); // Act var result = inventoryAccessor.CancelOrder(orderId); // Assert Assert.Equal($"Order {orderId} cancelled.", result); } finally { inventoryDbContext.ChangeTracker .Entries() .ToList() .ForEach(e => e.State = EntityState.Detached); inventoryDbContext.Database.EnsureDeleted(); } }
public void InventoryAccessor_CancelOrder_ForNotExistingOrder_ShouldReturnNull() { // Arrange using var inventoryDbContext = InventoryDbContext; try { var inventoryAccessor = new InventoryAccessor(inventoryDbContext, Mapper); // Act var result = inventoryAccessor.CancelOrder(99); // Assert Assert.Null(result); } finally { inventoryDbContext.ChangeTracker .Entries() .ToList() .ForEach(e => e.State = EntityState.Detached); inventoryDbContext.Database.EnsureDeleted(); } }
public string CancelOrder(int OrderId) { return(InventoryAccessor.CancelOrder(OrderId)); }