コード例 #1
0
        public void ApproveStockAdjustmentMobile_Valid()
        {
            // Arrange
            var stockAdjustmentRepository = new StockAdjustmentRepository(context);
            var stockAdjustmentService    = new StockAdjustmentService(context);

            var stockAdjustment = stockAdjustmentRepository.Save(new StockAdjustment()
            {
                StockAdjustmentId      = "ADJAPPROVETEST",
                CreatedBy              = new UserService(context).FindUserByEmail("*****@*****.**"),
                CreatedDateTime        = DateTime.Now,
                Status                 = new StatusService(context).FindStatusByStatusId(4),
                StockAdjustmentDetails = new List <StockAdjustmentDetail>()
                {
                    new StockAdjustmentDetail()
                    {
                        StockAdjustmentId = "ADJAPPROVETEST",
                        ItemCode          = "E030",
                        Item             = new ItemService(context).FindItemByItemCode("E030"),
                        OriginalQuantity = 10,
                        AfterQuantity    = 10,
                    }
                }
            });

            // Act
            stockAdjustmentService.ApproveStockAdjustment("ADJAPPROVETEST", "*****@*****.**");

            // Assert
            Assert.AreEqual(6, stockAdjustment.Status.StatusId);
            Assert.AreEqual(10, new StockMovementRepository(context).FindByStockAdjustmentId("ADJAPPROVETEST").FirstOrDefault().AfterQuantity);
        }
コード例 #2
0
        public void ApproveStockAdjustmentMobile_AlreadyApproved_ThrowsException()
        {
            // Arrange
            var stockAdjustmentRepository = new StockAdjustmentRepository(context);
            var stockAdjustmentService    = new StockAdjustmentService(context);

            var stockAdjustment = stockAdjustmentRepository.Save(new StockAdjustment()
            {
                StockAdjustmentId      = "ADJAPPROVETEST",
                CreatedBy              = new UserService(context).FindUserByEmail("*****@*****.**"),
                CreatedDateTime        = DateTime.Now,
                Status                 = new StatusService(context).FindStatusByStatusId(6),
                StockAdjustmentDetails = new List <StockAdjustmentDetail>()
                {
                    new StockAdjustmentDetail()
                    {
                        StockAdjustmentId = "ADJAPPROVETEST",
                        ItemCode          = "E030",
                        Item             = new ItemService(context).FindItemByItemCode("E030"),
                        OriginalQuantity = 10,
                        AfterQuantity    = 10,
                    }
                }
            });

            // Act
            stockAdjustmentService.ApproveStockAdjustment("ADJAPPROVETEST", "*****@*****.**");
        }
コード例 #3
0
        public void ApproveStockAdjustmentTest()
        {
            //Arrange
            Item item = context.Item.Where(x => x.ItemCode == "he06").First();


            StockAdjustmentDetail sd = new StockAdjustmentDetail();

            sd.Item             = item;
            sd.OriginalQuantity = 10;
            sd.AfterQuantity    = 20;

            List <StockAdjustmentDetail> list = new List <StockAdjustmentDetail>();

            list.Add(sd);

            StockAdjustment expect = new StockAdjustment();
            Random          rd     = new Random();
            int             i      = rd.Next();
            string          id     = "he07";

            expect.StockAdjustmentId      = id;
            expect.CreatedDateTime        = DateTime.Now;
            expect.StockAdjustmentDetails = list;
            service.CreatePendingStockAdjustment(expect);


            StockMovement sm = new StockMovement();

            try
            {
                //Act
                var result = service.ApproveStockAdjustment(id);
                sm = context.StockMovement.Where(x => x.Item.ItemCode == "he06").First();

                //Assert
                int latest_id = stockMovementRepository.Count();
                sm = stockMovementRepository.FindById(latest_id);


                Assert.IsTrue(expect.Status.StatusId == 6);
                Assert.IsTrue(item.Inventory.Quantity == 20);
                Assert.IsTrue(sm.AfterQuantity == 20);
                stockMovementRepository.Delete(sm);
                stockAdjustmentRepository.Delete(expect);
                itemRepository.Delete(item);
            }
            catch (Exception e)
            {
                Assert.IsTrue(e.Message.Contains("can't find StockAdjustment"));
            }
        }