Пример #1
0
        public void Will_successfully_create_an_InventoryPickOrderItem_with_null_Treatment()
        {
            //Arrange
            var order    = TestHelper.CreateObjectGraphAndInsertIntoDatabase <TOrder>(InitializeOrder, o => GetPickOrderFromOrder(o).Items = null);
            var orderKey = CreateKeyFromOrder(order);

            TestHelper.CreateObjectGraphAndInsertIntoDatabase <InventoryPickOrderItem>(i => i.InventoryPickOrder = null, i => ConstrainItemToOrder(i, GetPickOrderFromOrder(order)));

            var       chileProductKey0     = new ChileProductKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <ChileProduct>()).KeyValue;
            var       packagingProductKey0 = new PackagingProductKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <PackagingProduct>()).KeyValue;
            const int expectedQuantity0    = 10;

            var       chileProductKey1     = new ChileProductKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <ChileProduct>()).KeyValue;
            var       packagingProductKey1 = new PackagingProductKey(TestHelper.CreateObjectGraphAndInsertIntoDatabase <PackagingProduct>()).KeyValue;
            const int expectedQuantity1    = 20;

            //Act
            var testParams = new SetInventoryPickOrderParameters(orderKey.KeyValue)
            {
                UserToken = TestUser.UserName,
                InventoryPickOrderItems = new List <ISetInventoryPickOrderItemParameters>
                {
                    new SetInventoryPickOrderItemParameters
                    {
                        ProductKey   = chileProductKey0,
                        PackagingKey = packagingProductKey0,
                        TreatmentKey = null,
                        Quantity     = expectedQuantity0
                    },
                    new SetInventoryPickOrderItemParameters
                    {
                        ProductKey   = chileProductKey1,
                        PackagingKey = packagingProductKey1,
                        TreatmentKey = null,
                        Quantity     = expectedQuantity1
                    }
                }
            };
            var result = GetResult(testParams);

            //Assert
            result.AssertSuccess();
            var items = RVCUnitOfWork.InventoryPickOrderRepository.Filter(i => true, i => i.Items.Select(m => m.InventoryTreatment)).Single().Items.ToList();

            Assert.AreEqual(testParams.InventoryPickOrderItems.Count(), items.Count);
            testParams.InventoryPickOrderItems.ForEach(i => items.Single(r =>
                                                                         i.ProductKey == new ProductKey((IProductKey)r).KeyValue&&
                                                                         i.PackagingKey == new PackagingProductKey(r).KeyValue&&
                                                                         r.TreatmentId == 0 &&
                                                                         i.Quantity == r.Quantity));
        }
Пример #2
0
 protected abstract IResult GetResult(SetInventoryPickOrderParameters parameters);