public void Creates_PickedInventoryItem_records_as_expected() { //Arrange const int quantityPicked0 = 50; const int quantityPicked1 = 75; var inventory = TestHelper.CreateObjectGraphAndInsertIntoDatabase <Inventory>(i => i.Quantity = 100); var inventoryKey0 = new InventoryKey(inventory); var inventoryKey1 = new InventoryKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <Inventory>(i => i.Location.ConstrainByKeys(inventory.Location), i => i.Quantity = 100)); var destinationLocationKey = new LocationKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <Location>(l => l.ConstrainByKeys(inventory.Location.Facility))); //Act var result = Service.CreateIntraWarehouseOrder(new CreateIntraWarehouseOrderParameters { UserToken = TestUser.UserName, TrackingSheetNumber = 123.1m, OperatorName = "Oh operator", MovementDate = new DateTime(2012, 3, 29), PickedItems = new List <IIntraWarehouseOrderPickedItemParameters> { new IntraWarehouseOrderPickedItemParameters { InventoryKey = inventoryKey0.KeyValue, DestinationLocationKey = destinationLocationKey, Quantity = quantityPicked0 }, new IntraWarehouseOrderPickedItemParameters { InventoryKey = inventoryKey1.KeyValue, DestinationLocationKey = destinationLocationKey, Quantity = quantityPicked1 } } }); //Assert result.AssertSuccess(); var orderKey = new IntraWarehouseOrderKey(KeyParserHelper.ParseResult <IIntraWarehouseOrderKey>(result.ResultingObject).ResultingObject); var items = RVCUnitOfWork.IntraWarehouseOrderRepository.FindByKey(orderKey, i => i.PickedInventory.Items.Select(t => t.FromLocation), i => i.PickedInventory.Items.Select(t => t.CurrentLocation)) .PickedInventory.Items.ToList(); Assert.AreEqual(2, items.Count); var item0 = items.Single(i => inventoryKey0.Equals(new InventoryKey(i, i, i.FromLocation, i, i.ToteKey))); Assert.AreEqual(quantityPicked0, item0.Quantity); var item1 = items.Single(i => inventoryKey1.Equals(new InventoryKey(i, i, i.FromLocation, i, i.ToteKey))); Assert.AreEqual(quantityPicked1, item1.Quantity); }
internal bool Match(PickedInventoryParameters b) { return(InventoryKey.Equals(b.InventoryKey) && CurrentLocationKey.Equals(b.CurrentLocationKey) && CustomerLotCode == b.CustomerLotCode && CustomerProductCode == b.CustomerProductCode && (OrderItemKey == null ? b.OrderItemKey == null : OrderItemKey.Equals(b.OrderItemKey))); }
public void Will_successfuly_set_PickedInventoryItem_and_Inventory_records_as_expected_in_database() { //Arrange const int pickedItemToLeaveAlone_quantity = 10; const int pickedItemToUpdate_quantity = 12; const int pickedItemToUpdate_expectedQuantity = 7; const int inventoryItemToUpdate_quantity = 1; const int inventoryItemToUpdate_expectedQuantity = 6; const int pickedItemToCreate_expectedQuantity = 5; const int inventoryItemToRemove_quantity = 5; const int pickedItemToRemove_quantity = 22; const int inventoryItemToCreate_expectedQuantity = 22; var order = TestHelper.CreateObjectGraphAndInsertIntoDatabase <TOrder>(InitializeOrder, o => o.PickedInventory.Items = null); var orderKey = CreateKeyFromOrder(order); var pickedItemToLeaveAlone = TestHelper.CreateObjectGraphAndInsertIntoDatabase <PickedInventoryItem>(i => InitializeValidPickedInventoryItem(i, order, pickedItemToLeaveAlone_quantity)); var pickedItemToUpdate = TestHelper.CreateObjectGraphAndInsertIntoDatabase <PickedInventoryItem>(i => InitializeValidPickedInventoryItem(i, order, pickedItemToUpdate_quantity), i => i.FromLocation.Locked = false); var inventoryItemToUpdate = TestHelper.CreateObjectGraphAndInsertIntoDatabase <Inventory>(i => SetInventoryToPickedInventory(i, pickedItemToUpdate), i => i.Quantity = inventoryItemToUpdate_quantity); var inventoryItemToRemove = TestHelper.CreateObjectGraphAndInsertIntoDatabase <Inventory>(i => i.Lot.SetValidToPick(), i => i.Quantity = inventoryItemToRemove_quantity, i => SetupInventoryToPick(i).Location.Locked = false); var pickedItemToRemove = TestHelper.CreateObjectGraphAndInsertIntoDatabase <PickedInventoryItem>(i => InitializeValidPickedInventoryItem(i, order, pickedItemToRemove_quantity)); //Act var result = GetResult(orderKey.KeyValue, new SetPickedInventoryParameters { UserToken = TestUser.UserName, PickedInventoryItems = new List <IPickedInventoryItemParameters> { new SetPickedInventoryItemParameters { InventoryKey = new InventoryKey(pickedItemToLeaveAlone), Quantity = pickedItemToLeaveAlone_quantity }, new SetPickedInventoryItemParameters { InventoryKey = new InventoryKey(inventoryItemToUpdate), Quantity = pickedItemToUpdate_expectedQuantity }, new SetPickedInventoryItemParameters { InventoryKey = new InventoryKey(inventoryItemToRemove), Quantity = pickedItemToCreate_expectedQuantity } } }); //Assert result.AssertSuccess(); Assert.AreEqual(pickedItemToLeaveAlone_quantity, RVCUnitOfWork.PickedInventoryItemRepository.FindByKey(new PickedInventoryItemKey(pickedItemToLeaveAlone)).Quantity); Assert.AreEqual(pickedItemToUpdate_expectedQuantity, RVCUnitOfWork.PickedInventoryItemRepository.FindByKey(new PickedInventoryItemKey(pickedItemToUpdate)).Quantity); Assert.AreEqual(inventoryItemToUpdate_expectedQuantity, RVCUnitOfWork.InventoryRepository.FindByKey(new InventoryKey(inventoryItemToUpdate)).Quantity); var inventoryToRemoveKey = new InventoryKey(inventoryItemToRemove); Assert.AreEqual(pickedItemToCreate_expectedQuantity, RVCUnitOfWork.PickedInventoryItemRepository.All().ToList().Single(p => inventoryToRemoveKey.Equals(new InventoryKey(p))).Quantity); Assert.IsNull(RVCUnitOfWork.InventoryRepository.FindByKey(inventoryToRemoveKey)); Assert.IsNull(RVCUnitOfWork.PickedInventoryItemRepository.FindByKey(new PickedInventoryItemKey(pickedItemToRemove))); Assert.AreEqual(inventoryItemToCreate_expectedQuantity, RVCUnitOfWork.InventoryRepository.FindByKey(new InventoryKey(pickedItemToRemove)).Quantity); }