Ejemplo n.º 1
0
        public void ExistsByIdTestIsTrue()
        {
            var expected = new PurchaseOrderDetail()
            {
                PurchaseOrderNo = "PODREPOTEST",
                ItemCode        = "E030",
            };

            purchaseOrderRepository.Save(new PurchaseOrder()
            {
                PurchaseOrderNo = "PODREPOTEST",
                CreatedDateTime = DateTime.Now,
            });
            purchaseOrderDetailRepository.Save(expected);

            // Act
            var result = purchaseOrderDetailRepository.ExistsById("PODREPOTEST", "E030");

            // Assert
            Assert.IsTrue(result);
        }
        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);
            }
        }