public void FindByIdTestNotNull()
        {
            // Arrange
            deliveryOrderRepository.Save(new DeliveryOrder()
            {
                DeliveryOrderNo = "DOREPOTEST",
                CreatedDateTime = DateTime.Now,
            });

            // Act
            var result = deliveryOrderRepository.FindById("DOREPOTEST");

            // Assert
            Assert.IsInstanceOfType(result, typeof(DeliveryOrder));
        }
예제 #2
0
        public void TestCleanup()
        {
            if (deliveryOrderDetailRepository.ExistsById("DODREPOTEST", "E030"))
            {
                deliveryOrderDetailRepository.Delete(deliveryOrderDetailRepository.FindById("DODREPOTEST", "E030"));
            }

            if (deliveryOrderDetailRepository.ExistsById("DODREPOTEST", "P030"))
            {
                deliveryOrderDetailRepository.Delete(deliveryOrderDetailRepository.FindById("DODREPOTEST", "P030"));
            }

            if (deliveryOrderRepository.ExistsById("DODREPOTEST"))
            {
                deliveryOrderRepository.Delete(deliveryOrderRepository.FindById("DODREPOTEST"));
            }
        }
예제 #3
0
        public void SaveDeliveryOrderDetailsTest()
        {
            //Arrange

            PurchaseOrder PO = purchaseOrderRepository.FindById("VALLI");
            DeliveryOrder DO = deliveryOrderRepository.FindById("DOTEST");

            DeliveryOrderDetail dod = new DeliveryOrderDetail()
            {
                DeliveryOrderNo = "DOTEST",
                ItemCode        = itemRepository.FindById("C003").ItemCode,
                PlanQuantity    = 100,
                ActualQuantity  = 50,
                Status          = statusRepository.FindById(0)
            };

            //Act
            var result = deliveryOrderService.SaveDeliveryOrderDetails(dod);

            //Assert
            Assert.AreEqual("DOTEST", result.DeliveryOrderNo);

            deliveryOrderDetailRepository.Delete(dod);
        }
 public DeliveryOrder FindDeliveryOrderById(string deliveryOrderNo)
 {
     return(deliveryOrderRepository.FindById(deliveryOrderNo));
 }
        public void Cleanup()
        {
            //1
            bool check = purchaseOrderRepository.ExistsById("PUR-1");

            if (check)
            {
                purchaseOrderRepository.Delete(purchaseOrderRepository.FindById("PUR-1"));
            }

            check = purchaseOrderRepository.ExistsById("PUR-3");
            if (check)
            {
                purchaseOrderRepository.Delete(purchaseOrderRepository.FindById("PUR-3"));
            }

            check = supplierRepository.ExistsById("SUP1");
            if (check)
            {
                supplierRepository.Delete(supplierRepository.FindById("SUP1"));
            }

            check = itemRepository.ExistsById("IT8");
            if (check)
            {
                itemRepository.Delete(itemRepository.FindById("IT8"));
            }

            check = itemRepository.ExistsById("IT9");
            if (check)
            {
                itemRepository.Delete(itemRepository.FindById("IT9"));
            }

            check = purchaseOrderRepository.ExistsById("PUR-4");
            if (check)
            {
                purchaseOrderRepository.Delete(purchaseOrderRepository.FindById("PUR-4"));
            }



            //3
            bool exist = purchaseOrderRepository.ExistsById("TEST10");

            if (exist)
            {
                purchaseOrderRepository.Delete(purchaseOrderRepository.FindById("TEST10"));
            }

            //5
            exist = purchaseOrderRepository.ExistsById("DUMMY");
            if (exist)
            {
                purchaseOrderRepository.Delete(purchaseOrderRepository.FindById("DUMMY"));
            }

            //6

            exist = purchaseOrderRepository.ExistsById("DUMMYS1");
            if (exist)
            {
                purchaseOrderRepository.Delete(purchaseOrderRepository.FindById("DUMMYS1"));
            }

            exist = purchaseOrderRepository.ExistsById("DUMMYS2");
            if (exist)
            {
                purchaseOrderRepository.Delete(purchaseOrderRepository.FindById("DUMMYS2"));
            }

            exist = purchaseOrderRepository.ExistsById("DUMMYS3");
            if (exist)
            {
                purchaseOrderRepository.Delete(purchaseOrderRepository.FindById("DUMMYS3"));
            }

            //7
            exist = purchaseOrderRepository.ExistsById("DUMMYSA1");
            if (exist)
            {
                purchaseOrderRepository.Delete(purchaseOrderRepository.FindById("DUMMYSA1"));
            }

            exist = purchaseOrderRepository.ExistsById("DUMMYSA2");
            if (exist)
            {
                purchaseOrderRepository.Delete(purchaseOrderRepository.FindById("DUMMYSA2"));
            }

            exist = purchaseOrderRepository.ExistsById("STATUSTEST");
            if (exist)
            {
                purchaseOrderRepository.Delete(purchaseOrderRepository.FindById("STATUSTEST"));
            }

            //11
            exist = purchaseOrderRepository.ExistsById("PO1");
            if (exist)
            {
                purchaseOrderRepository.Delete(purchaseOrderRepository.FindById("PO1"));
            }

            exist = purchaseOrderDetailRepository.ExistsById("PO1", "ITEM");
            if (exist)
            {
                purchaseOrderDetailRepository.Delete(purchaseOrderDetailRepository.FindById("PO1", "ITEM"));
            }

            exist = itemRepository.ExistsById("ITEM");
            if (exist)
            {
                itemRepository.Delete(itemRepository.FindById("ITEM"));
            }

            exist = itemPriceRepository.ExistsById("ITEM", "CHEP");
            if (exist)
            {
                itemPriceRepository.Delete(itemPriceRepository.FindById("ITEM", "CHEP"));
            }


            //12
            exist = purchaseOrderRepository.ExistsById("PO2");
            if (exist)
            {
                purchaseOrderRepository.Delete(purchaseOrderRepository.FindById("PO2"));
            }


            exist = itemRepository.ExistsById("ITM2");
            if (exist)
            {
                itemRepository.Delete(itemRepository.FindById("ITM2"));
            }

            exist = itemPriceRepository.ExistsById("ITM2", "CHEP");
            if (exist)
            {
                itemPriceRepository.Delete(itemPriceRepository.FindById("ITM2", "CHEP"));
            }



            //13
            exist = deliveryOrderRepository.ExistsById("DO1");
            if (exist)
            {
                deliveryOrderRepository.Delete(deliveryOrderRepository.FindById("DO1"));
            }

            exist = deliveryOrderRepository.ExistsById("DO2");
            if (exist)
            {
                deliveryOrderRepository.Delete(deliveryOrderRepository.FindById("DO2"));
            }

            exist = purchaseOrderRepository.ExistsById("PO3");
            if (exist)
            {
                purchaseOrderRepository.Delete(purchaseOrderRepository.FindById("PO3"));
            }

            exist = itemRepository.ExistsById("IT3");
            if (exist)
            {
                itemRepository.Delete(itemRepository.FindById("IT3"));
            }

            exist = itemRepository.ExistsById("IT4");
            if (exist)
            {
                itemRepository.Delete(itemRepository.FindById("IT4"));
            }

            //14

            exist = deliveryOrderRepository.ExistsById("DO3");
            if (exist)
            {
                deliveryOrderRepository.Delete(deliveryOrderRepository.FindById("DO3"));
            }

            exist = deliveryOrderRepository.ExistsById("DO4");
            if (exist)
            {
                deliveryOrderRepository.Delete(deliveryOrderRepository.FindById("DO4"));
            }

            exist = purchaseOrderRepository.ExistsById("PO4");
            if (exist)
            {
                purchaseOrderRepository.Delete(purchaseOrderRepository.FindById("PO4"));
            }

            exist = itemRepository.ExistsById("IT5");
            if (exist)
            {
                itemRepository.Delete(itemRepository.FindById("IT5"));
            }

            exist = itemRepository.ExistsById("IT6");
            if (exist)
            {
                itemRepository.Delete(itemRepository.FindById("IT6"));
            }


            List <PurchaseOrder> poLIST = context.PurchaseOrder.Where(x => x.ApprovedDateTime == new DateTime(1993, 7, 9)).ToList();

            foreach (PurchaseOrder p in poLIST)
            {
                purchaseOrderRepository.Delete(p);
            }
        }
        public void TestInitialize()
        {
            context = new ApplicationDbContext();

            stockmovementService = new StockMovementService(context);
            itemService          = new ItemService(context);

            stockmovementRepository = new StockMovementRepository(context);

            ddRepository           = new DisbursementDetailRepository(context);
            sadRepository          = new StockAdjustmentDetailRepository(context);
            dodRepository          = new DeliveryOrderDetailRepository(context);
            disbursementRepository = new DisbursementRepository(context);
            doRepository           = new DeliveryOrderRepository(context);
            saRepository           = new StockAdjustmentRepository(context);

            //create new test object and save into db
            StockMovement sm = new StockMovement()
            {
                StockMovementId   = IdService.GetNewStockMovementId(context),
                DisbursementId    = "TEST",
                StockAdjustmentId = "TEST",
                DeliveryOrderNo   = "TEST",
                Item             = context.Item.Where(x => x.ItemCode == "C003").First(),
                CreatedDateTime  = DateTime.Now,
                OriginalQuantity = 1,
                AfterQuantity    = 2
            };

            stockmovementRepository.Save(sm);

            //create new disbursement object and save into db
            Disbursement disbursement = new Disbursement();

            if (disbursementRepository.FindById("TEST") == null)
            {
                disbursement.DisbursementId  = "TEST";
                disbursement.CreatedDateTime = DateTime.Now;
            }
            else
            {
                disbursement = disbursementRepository.FindById("TEST");
            }
            disbursementRepository.Save(disbursement);

            //create new DisbursementDetail object and save into db
            DisbursementDetail detail = new DisbursementDetail()
            {
                DisbursementId = "TEST",
                Item           = context.Item.First(),
                PlanQuantity   = 3,
                ActualQuantity = 3
            };

            ddRepository.Save(detail);

            //create new DO object and save into db
            DeliveryOrder d = new DeliveryOrder();

            if (doRepository.FindById("TEST") == null)
            {
                d.DeliveryOrderNo = "TEST";
                d.CreatedDateTime = DateTime.Now;
            }
            else
            {
                d = doRepository.FindById("TEST");
            }
            doRepository.Save(d);

            //create new DO detail object and save into db
            DeliveryOrderDetail dod = new DeliveryOrderDetail()
            {
                DeliveryOrder  = d,
                Item           = context.Item.First(),
                PlanQuantity   = 4,
                ActualQuantity = 4
            };

            dodRepository.Save(dod);

            //create new SA object and save into db
            StockAdjustment SA = new StockAdjustment();

            if (saRepository.FindById("TEST") == null)
            {
                SA.StockAdjustmentId = "TEST";
                SA.CreatedDateTime   = DateTime.Now;
            }
            else
            {
                SA = saRepository.FindById("TEST");
            }
            saRepository.Save(SA);

            //create new SA detail object and save into db
            StockAdjustmentDetail SADetail = new StockAdjustmentDetail()
            {
                StockAdjustment  = SA,
                Item             = context.Item.First(),
                OriginalQuantity = 2,
                AfterQuantity    = 4
            };

            sadRepository.Save(SADetail);
        }