示例#1
0
        public void TestOutboundOrder()
        {
            onSetUp();
            stockRepository.AddStock(WAREHOUSE_ID, new List <StockAlteration>()
            {
                new StockAlteration(productId, 10)
            });
            var outboundOrder = new OutboundOrderRequestModel()
            {
                WarehouseId = WAREHOUSE_ID,
                OrderLines  = new List <OrderLine>()
                {
                    new OrderLine()
                    {
                        gtin     = GTIN,
                        quantity = 3
                    }
                }
            };

            outboundOrderController.Post(outboundOrder);

            var stock = stockRepository.GetStockByWarehouseAndProductIds(WAREHOUSE_ID, new List <int>()
            {
                productId
            })[productId];

            Assert.AreEqual(stock.held, 7);
        }
        public void TestOutboundOrder()
        {
            OnSetUp();
            _stockRepository.AddStock(WarehouseId, new List <StockAlteration> {
                new StockAlteration(_productId, 10)
            });
            var outboundOrder = new OutboundOrderRequestModel
            {
                WarehouseId = WarehouseId,
                OrderLines  = new List <OrderLine>
                {
                    new OrderLine
                    {
                        Gtin     = Gtin,
                        Quantity = 3
                    }
                }
            };

            _outboundOrderController.Post(outboundOrder);

            var stock =
                _stockRepository.GetStockByWarehouseAndProductIds(WarehouseId, new List <int> {
                _productId
            })[_productId];

            Assert.AreEqual(stock.Held, 7);
        }
示例#3
0
        public void TestCreateOrderProductHoldingNoStock()
        {
            OnSetUp();
            _stockRepository.AddStock(WarehouseId, new List <StockAlteration> {
                new StockAlteration(_productId, 0)
            });

            var inboundOrder = _inboundOrderController.Get(WarehouseId);

            Assert.AreEqual(inboundOrder.OrderSegments.Count(), 1);
            var orderSegment = inboundOrder.OrderSegments.First();

            Assert.AreEqual(orderSegment.Company.Gcp, Gcp);
        }
示例#4
0
        public void TestAddNewStock()
        {
            OnSetUp();
            var productId = _productRepository.GetProductByGtin(Gtin).Id;

            _stockRepository.AddStock(1, new List <StockAlteration> {
                new StockAlteration(productId, 1)
            });

            var databaseStock = _stockRepository.GetStockByWarehouseAndProductIds(1, new List <int> {
                productId
            });

            Assert.AreEqual(databaseStock[productId].Held, 1);
        }
示例#5
0
        public void TestCreateOrderProductHoldingNoStock()
        {
            onSetUp();
            stockRepository.AddStock(WAREHOUSE_ID, new List <StockAlteration>()
            {
                new StockAlteration(productId, 0)
            });

            var inboundOrder = inboundOrderController.Get(WAREHOUSE_ID);

            Assert.AreEqual(inboundOrder.OrderSegments.Count(), 1);
            var orderSegment = inboundOrder.OrderSegments.First();

            Assert.AreEqual(orderSegment.Company.Gcp, GCP);
        }
示例#6
0
        public async Task StockRep_AddStock_AddsStock()
        {
            // Arrange
            string currentTime = System.DateTime.Now.ToString();
            var    stockRep    = new StockRepository(new AmazonDynamoDBClient());
            var    mapper      = new Mapper();

            Document newStock = new Document
            {
                ["Name"]        = "NEWSTOCK",
                ["Price"]       = 135.79,
                ["LastUpdated"] = currentTime
            };

            var mappedStock = mapper.ToStockContract(newStock);
            // Act
            await stockRep.AddStock(newStock);

            var result = mapper.ToStockContract(await stockRep.GetStockByName(newStock["Name"]));

            // Assert
            Assert.AreEqual(mappedStock.Name, result.Name);
            Assert.AreEqual(mappedStock.Price, result.Price);
            Assert.AreEqual(mappedStock.LastUpdated, result.LastUpdated);
            // Clean-up
            await stockRep.DeleteStock(newStock);
        }
示例#7
0
        public async Task StockRep_UpdateStock_UpdatesStock()
        {
            // Arrange
            var stockRep = new StockRepository(new AmazonDynamoDBClient());

            Document oldStock = new Document
            {
                ["Name"]        = "UPDATEME",
                ["Price"]       = 000.00,
                ["LastUpdated"] = System.DateTime.Now.ToString()
            };

            Document newStock = new Document
            {
                ["Name"]        = "UPDATEME",
                ["Price"]       = 123.45,
                ["LastUpdated"] = System.DateTime.Now.ToString()
            };
            // Act
            await stockRep.AddStock(oldStock);

            var result1 = await stockRep.GetStockByName(oldStock["Name"]);

            await stockRep.UpdateStock(newStock);

            var result2 = await stockRep.GetStockByName(newStock["Name"]);

            // Assert
            Assert.AreNotEqual(result1["Price"], result2["Price"]);
            // Clean-up
            await stockRep.DeleteStock(newStock);
        }
示例#8
0
        public void TestAddNewStock()
        {
            onSetUp();
            var productId = productRepository.GetProductByGtin(GTIN).Id;

            stockRepository.AddStock(1, new List <StockAlteration>()
            {
                new StockAlteration(productId, 1, 200)
            });

            var databaseStock = stockRepository.GetStockByWarehouseAndProductIds(1, new List <int>()
            {
                productId
            });

            Assert.AreEqual(databaseStock[productId].held, 1);
        }
        public void StockRepositoryTest_AddStock_Sucess()
        {
            try
            {
                StockRepository stoqueRepository = new StockRepository();
                Stock stock = stoqueRepository.GetByIDs(1);
                stock.Quantity = 10;
                int actual = stoqueRepository.AddStock(stock);
                Assert.AreEqual(1, actual);
            }
            catch (Exception)
            {

                throw;
            }
        }
        public void ShouldIncreaseStockCountOnIncrement()
        {
            var stockId    = 1;
            var stockLevel = 0;

            var stockItem = new StockItem()
            {
                Id    = stockId,
                Stock = stockLevel
            };

            var stock = InitializeWithStock(stockItem);

            _stockRepository
            .AddStock(stockId);

            stockItem = _stockRepository
                        .GetStockItem(stockId);

            stockItem.Stock.ShouldBe(stockLevel + 1);
        }
示例#11
0
        public void AddStockDetails()
        {
            Console.Write("Enter Stock Id: ");
            int id = Convert.ToInt32(Console.ReadLine());

            Console.Write("Enter Stock Name: ");
            string name = Console.ReadLine();

            Console.Write("Enter Stock cost price: ");
            double costPrice = Convert.ToDouble(Console.ReadLine());

            Console.Write("Enter Stock selling price: ");
            double sellingPrice = Convert.ToDouble(Console.ReadLine());

            Console.Write("Enter Stock SKU: ");
            string sKU = Console.ReadLine();

            Console.Write("Enter Stock quantity: ");
            int quantity = Convert.ToInt32(Console.ReadLine());

            Console.Write("Enter Stock variation: ");
            string variation = Console.ReadLine();

            DateTime created_at = DateTime.Now;

            ReshuffleMenu();
            Console.WriteLine("Choose Category. ");
            int category_Id = Convert.ToInt32(Console.ReadLine());

            List <Stock> Stocks = stockRepository.ListAllStocks();

            foreach (var stock in Stocks)
            {
                stock.Category_Id = category_Id;
            }
            stockRepository.AddStock(id, name, costPrice, sellingPrice, sKU, quantity, variation, created_at, category_Id);
        }
示例#12
0
        public async Task StockRep_DeleteStock_DeletesStock()
        {
            // Arrange
            string currentTime = System.DateTime.Now.ToString();
            var    stockRep    = new StockRepository(new AmazonDynamoDBClient());

            Document testStock = new Document
            {
                ["Name"]        = "DELETEME",
                ["Price"]       = 112.23,
                ["LastUpdated"] = currentTime
            };
            // Act
            await stockRep.AddStock(testStock);

            var result1 = await stockRep.GetStockByName(testStock["Name"]);

            await stockRep.DeleteStock(testStock);

            var result2 = await stockRep.GetStockByName(testStock["Name"]);

            // Assert
            Assert.AreNotEqual(result1, result2);
        }
        public void AddStock(int id, string name, double costPrice, double sellingPrice, string sKU, int quantity, string variation, int category_Id)
        {
            Stock stock = new Stock(id, name, costPrice, sellingPrice, sKU, quantity, variation, category_Id);

            stockRepository.AddStock(stock);
        }