Пример #1
0
            public void Returns_IntraWarehouseOrder_with_details_as_expected()
            {
                //Arrange
                StartStopwatch();

                const int expectedNumberOfItems = 3;
                var       intraWarehouseOrder   = TestHelper.CreateObjectGraphAndInsertIntoDatabase <IntraWarehouseOrder>(o => o.PickedInventory.Items = null);
                var       pickedItem0           = TestHelper.CreateObjectGraphAndInsertIntoDatabase <PickedInventoryItem>(i => i.ConstrainByKeys(intraWarehouseOrder));
                var       pickedKey0            = new PickedInventoryItemKey(pickedItem0);
                var       pickedItem1           = TestHelper.CreateObjectGraphAndInsertIntoDatabase <PickedInventoryItem>(i => i.ConstrainByKeys(intraWarehouseOrder));
                var       pickedKey1            = new PickedInventoryItemKey(pickedItem1);
                var       pickedItem2           = TestHelper.CreateObjectGraphAndInsertIntoDatabase <PickedInventoryItem>(i => i.ConstrainByKeys(intraWarehouseOrder));
                var       pickedKey2            = new PickedInventoryItemKey(pickedItem2);

                StopWatchAndWriteTime("Arrange");

                //Act
                var result = TimedExecution(() => Service.GetIntraWarehouseOrders());

                //Assert
                result.AssertSuccess();
                var warehouseOrder = result.ResultingObject.FirstOrDefault(o => o.TrackingSheetNumber == intraWarehouseOrder.TrackingSheetNumber);

                Assert.AreEqual(new PickedInventoryKey(intraWarehouseOrder).KeyValue, warehouseOrder.PickedInventory.PickedInventoryKey);

                var items = warehouseOrder.PickedInventory.PickedInventoryItems.ToList();

                Assert.AreEqual(expectedNumberOfItems, items.Count);
                Assert.IsNotNull(items.Single(i => pickedKey0.KeyValue == i.PickedInventoryItemKey));
                Assert.IsNotNull(items.Single(i => pickedKey1.KeyValue == i.PickedInventoryItemKey));
                Assert.IsNotNull(items.Single(i => pickedKey2.KeyValue == i.PickedInventoryItemKey));
            }
Пример #2
0
        public void Returns_PickedInventoryItems_with_LoBac_properties_as_expected_on_success()
        {
            //Arrange
            StartStopwatch();

            var nullLoBacLot = TestHelper.CreateObjectGraphAndInsertIntoDatabase <Lot>(l => l.EmptyLot().NullDerivedLots());
            var notLoBacLot  = TestHelper.CreateObjectGraphAndInsertIntoDatabase <ChileLot>(c => c.AllAttributesAreLoBac = false, c => c.SetLotType().Lot.EmptyLot());
            var loBacLot     = TestHelper.CreateObjectGraphAndInsertIntoDatabase <ChileLot>(c => c.AllAttributesAreLoBac = true, c => c.SetLotType().Lot.EmptyLot());

            var parentRecord    = CreateParentRecord();
            var pickedInventory = GetPickedInventoryRecordFromParent(parentRecord);
            var pickedKey0      = new PickedInventoryItemKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <PickedInventoryItem>(i => i.ConstrainByKeys(pickedInventory, nullLoBacLot)));
            var pickedKey1      = new PickedInventoryItemKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <PickedInventoryItem>(i => i.ConstrainByKeys(pickedInventory, notLoBacLot)));
            var pickedKey2      = new PickedInventoryItemKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <PickedInventoryItem>(i => i.ConstrainByKeys(pickedInventory, loBacLot)));

            StopWatchAndWriteTime("Arrange");

            //Act
            var result = TimedExecution(() => MethodUnderTest(parentRecord));

            //Assert
            result.AssertSuccess();
            var items = GetPickedInventoryItemsFromResult(result.ResultingObject);

            Assert.IsNull(items.Single(i => i.PickedInventoryItemKey == pickedKey0.KeyValue).LoBac);
            Assert.IsFalse((bool)items.Single(i => i.PickedInventoryItemKey == pickedKey1.KeyValue).LoBac);
            Assert.IsTrue((bool)items.Single(i => i.PickedInventoryItemKey == pickedKey2.KeyValue).LoBac);
        }
        public ModifyPickedInventoryItemParameters(PickedInventoryItem pickedItem)
        {
            if (pickedItem.CurrentLocation == null)
            {
                throw new ArgumentNullException("Expected pickedItem.CurrentLocation but was null, verify navigational property is being included in selection.");
            }

            PickedInventoryItemKey = new PickedInventoryItemKey(pickedItem);
            InventoryKey           = new InventoryKey(pickedItem, pickedItem, pickedItem, pickedItem, pickedItem.ToteKey);
            CurrentLocationKey     = new LocationKey(pickedItem.CurrentLocation);
            OriginalQuantity       = pickedItem.Quantity;
            CustomerLotCode        = pickedItem.CustomerLotCode;
            CustomerProductCode    = pickedItem.CustomerProductCode;
            NewQuantity            = 0;
        }
Пример #4
0
        public void Returns_PickedInventoryItems_with_Lot_status_properties_as_expected_on_success()
        {
            //Arrange
            StartStopwatch();

            const LotQualityStatus    lotStatus0        = LotQualityStatus.Contaminated;
            const bool                onHold0           = false;
            const LotProductionStatus productionStatus0 = LotProductionStatus.Batched;

            const LotQualityStatus    lotStatus1 = LotQualityStatus.Pending;
            const bool                onHold1    = true;
            const LotProductionStatus status1    = LotProductionStatus.Produced;

            var lotKey0 = new LotKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <Lot>(l => l.EmptyLot(), l => l.QualityStatus = lotStatus0, l => l.ProductionStatus = productionStatus0, l => l.Hold = null));
            var lotKey1 = new LotKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <Lot>(l => l.EmptyLot(), l => l.QualityStatus = lotStatus1, l => l.ProductionStatus = status1, l => l.Hold = LotHoldType.HoldForAdditionalTesting));

            var parentRecord    = CreateParentRecord();
            var pickedInventory = GetPickedInventoryRecordFromParent(parentRecord);
            var pickedKey0      = new PickedInventoryItemKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <PickedInventoryItem>(i => i.ConstrainByKeys(pickedInventory, lotKey0)));
            var pickedKey1      = new PickedInventoryItemKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <PickedInventoryItem>(i => i.ConstrainByKeys(pickedInventory, lotKey1)));

            StopWatchAndWriteTime("Arrange");

            //Act
            var result = TimedExecution(() => MethodUnderTest(parentRecord));

            //Assert
            result.AssertSuccess();
            var items = GetPickedInventoryItemsFromResult(result.ResultingObject);

            var inventory = items.Single(r => r.PickedInventoryItemKey == pickedKey0.KeyValue);

            Assert.AreEqual(lotStatus0, inventory.QualityStatus);
            Assert.AreEqual(onHold0, inventory.HoldType != null);
            Assert.AreEqual(productionStatus0, inventory.ProductionStatus);

            inventory = items.Single(r => r.PickedInventoryItemKey == pickedKey1.KeyValue);
            Assert.AreEqual(lotStatus1, inventory.QualityStatus);
            Assert.AreEqual(onHold1, inventory.HoldType != null);
            Assert.AreEqual(status1, inventory.ProductionStatus);
        }
Пример #5
0
        public void Returns_PickedInventoryItems_with_AstaCalc_properties_as_expected_on_success()
        {
            //Arrange
            StartStopwatch();

            const double originalAsta     = 120.0;
            var          now              = DateTime.UtcNow;
            var          productionEnd    = now.AddDays(-200);
            var          expectedAstaCalc = AstaCalculator.CalculateAsta(originalAsta, productionEnd, productionEnd, now);
            var          asta             = StaticAttributeNames.Asta;

            var lot          = TestHelper.CreateObjectGraphAndInsertIntoDatabase <Lot>(l => l.EmptyLot());
            var chileLot     = TestHelper.CreateObjectGraphAndInsertIntoDatabase <ChileLot>(c => c.Lot.EmptyLot());
            var astaChileLot = TestHelper.CreateObjectGraphAndInsertIntoDatabase <ChileLot>(c => c.Lot.EmptyLot(), c => c.Production.Results.EmptyItems().ProductionEnd = productionEnd);

            TestHelper.CreateObjectGraphAndInsertIntoDatabase <LotAttribute>(a => a.SetValues(astaChileLot, asta, originalAsta).AttributeDate = productionEnd);

            var parentRecord    = CreateParentRecord();
            var pickedInventory = GetPickedInventoryRecordFromParent(parentRecord);
            var picked0         = TestHelper.CreateObjectGraphAndInsertIntoDatabase <PickedInventoryItem>(i => i.ConstrainByKeys(pickedInventory, lot));
            var picked1         = TestHelper.CreateObjectGraphAndInsertIntoDatabase <PickedInventoryItem>(i => i.ConstrainByKeys(pickedInventory, chileLot));
            var picked2         = TestHelper.CreateObjectGraphAndInsertIntoDatabase <PickedInventoryItem>(i => i.ConstrainByKeys(pickedInventory, astaChileLot));

            TestHelper.ResetContext();
            StopWatchAndWriteTime("Arrange");

            //Act
            var result = TimedExecution(() => MethodUnderTest(parentRecord));

            //Assert
            result.AssertSuccess();
            var items      = GetPickedInventoryItemsFromResult(result.ResultingObject);
            var pickedKey0 = new PickedInventoryItemKey(picked0);
            var pickedKey1 = new PickedInventoryItemKey(picked1);
            var pickedKey2 = new PickedInventoryItemKey(picked2);

            Assert.IsNull(items.Single(i => i.PickedInventoryItemKey == pickedKey0.KeyValue).AstaCalc);
            Assert.IsNull(items.Single(i => i.PickedInventoryItemKey == pickedKey1.KeyValue).AstaCalc);
            Assert.AreEqual(expectedAstaCalc, items.Single(i => i.PickedInventoryItemKey == pickedKey2.KeyValue).AstaCalc);
        }
Пример #6
0
        private static IResult <List <ModifyInventoryParameters> > PostOrder(Parameters parameters, InventoryShipmentOrder order, IEmployeeKey employee)
        {
            if (order == null)
            {
                throw new ArgumentNullException("order");
            }
            if (employee == null)
            {
                throw new ArgumentNullException("order");
            }

            if (order.OrderStatus == OrderStatus.Fulfilled)
            {
                switch (order.OrderType)
                {
                case InventoryShipmentOrderTypeEnum.InterWarehouseOrder:
                    return(new InvalidResult <List <ModifyInventoryParameters> >(null, string.Format(UserMessages.InterWarehouseOrderAlreadyFulfilled, order.ToInventoryShipmentOrderKey())));

                case InventoryShipmentOrderTypeEnum.TreatmentOrder:
                    return(new InvalidResult <List <ModifyInventoryParameters> >(null, string.Format(UserMessages.TreatmentOrderAlreadyFulfilled, order.ToInventoryShipmentOrderKey())));

                case InventoryShipmentOrderTypeEnum.SalesOrder:
                case InventoryShipmentOrderTypeEnum.MiscellaneousOrder:
                    return(new InvalidResult <List <ModifyInventoryParameters> >(null, string.Format(UserMessages.SalesOrderAlreadyFulfilled, order.ToInventoryShipmentOrderKey())));

                default: throw new ArgumentOutOfRangeException("order.OrderType");
                }
            }

            if (order.ShipmentInformation.Status == ShipmentStatus.Shipped)
            {
                return(new InvalidResult <List <ModifyInventoryParameters> >(null, string.Format(UserMessages.ShipmentStatusCannotPost, order.ShipmentInformation.Status)));
            }

            var inventoryModifications = new List <ModifyInventoryParameters>();

            foreach (var item in order.PickedInventory.Items)
            {
                var pickedItemKey  = new PickedInventoryItemKey(item);
                var itemParameters = parameters.ItemParams.FirstOrDefault(i => i.ItemKey.Equals(pickedItemKey));
                if (itemParameters == null)
                {
                    if (order.DestinationFacility != null)
                    {
                        return(new InvalidResult <List <ModifyInventoryParameters> >(null, string.Format(UserMessages.DestinationLocationRequiredForPicked, pickedItemKey)));
                    }
                }
                else if (itemParameters.DestinationKey != null)
                {
                    if (order.DestinationFacility != null && !order.DestinationFacility.Locations.Any(l => itemParameters.DestinationKey.Equals(l)))
                    {
                        return(new InvalidResult <List <ModifyInventoryParameters> >(null, string.Format(UserMessages.DestinationLocationMustBelongToFacility, new FacilityKey(order.DestinationFacility))));
                    }

                    item.CurrentLocationId = itemParameters.DestinationKey.LocationKey_Id;
                    inventoryModifications.Add(item.ToModifyInventoryDestinationParameters(itemParameters.DestinationKey));
                }
            }

            order.ShipmentInformation.Status = ShipmentStatus.Shipped;
            order.EmployeeId = employee.EmployeeKey_Id;

            return(new SuccessResult <List <ModifyInventoryParameters> >(inventoryModifications));
        }