public async Task TestUpdateInventory() { var item = _context.Inventory.First(); var totalCount = item.Count; await _context.CreatePartCommand(new PartCommand() { PartTypeId = item.PartTypeId, PartCount = totalCount, Command = PartCountOperation.Remove }); var inventory = new Inventory(_context); await inventory.UpdateInventory(); var order = (await _context.GetOrders()).FirstOrDefault( o => o.PartTypeId == item.PartTypeId && !o.FulfilledDate.HasValue ); Assert.NotNull(order); await _context.CreatePartCommand(new PartCommand() { PartTypeId = item.PartTypeId, PartCount = totalCount, Command = PartCountOperation.Add }); await inventory.UpdateInventory(); Assert.Equal(totalCount, item.Count); }
public void TestUpdateInventory() { var item = context.Inventory.First(); var totalCount = item.Count; context.CreatePartCommand(new PartCommand() { PartTypeId = item.PartTypeId, PartCount = totalCount, Command = PartCountOperation.Remove }); var inventory = new Inventory(context); inventory.UpdateInventory(); var order = context.GetOrders().FirstOrDefault( o => o.PartTypeId == item.PartTypeId && !o.FulfilledDate.HasValue); Assert.NotNull(order); var mails = context.GetMails(); Assert.Equal(1, mails.Count()); context.CreatePartCommand(new PartCommand() { PartTypeId = item.PartTypeId, PartCount = totalCount, Command = PartCountOperation.Add }); inventory.UpdateInventory(); Assert.Equal(totalCount, item.Count); }