public void TestInitialize()
        {
            context = new ApplicationDbContext();

            retrievalService    = new RetrievalService(context);
            itemService         = new ItemService(context);
            disbursementService = new DisbursementService(context);

            retrievalRepository          = new RetrievalRepository(context);
            disbursementRepository       = new DisbursementRepository(context);
            disbursementdetailRepository = new DisbursementDetailRepository(context);
            stockmovementRepository      = new StockMovementRepository(context);
            statusRepository             = new StatusRepository(context);

            Retrieval retrieval = new Retrieval();

            if (retrievalRepository.FindById("TEST") == null)
            {
                //save retrieval object into db

                retrieval.RetrievalId     = "TEST";
                retrieval.CreatedDateTime = DateTime.Now;
                retrievalRepository.Save(retrieval);
                retrieval.Status = statusRepository.FindById(19);
            }
            else
            {
                retrieval = retrievalRepository.FindById("TEST");
            }

            Disbursement disbursement = new Disbursement();

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

            disbursementRepository.Save(disbursement);

            //save disbursement detail object into db
            DisbursementDetail detail = new DisbursementDetail()
            {
                Disbursement   = disbursement,
                Item           = context.Item.Where(x => x.ItemCode == "C003").First(),
                PlanQuantity   = 5,
                ActualQuantity = 5
            };

            disbursementdetailRepository.Save(detail);
        }
        public void FindByIdTestNotNull()
        {
            // Arrange
            retrievalRepository.Save(new Retrieval()
            {
                RetrievalId     = "RTREPOTEST",
                CreatedDateTime = DateTime.Now,
            });

            // Act
            var result = retrievalRepository.FindById("RTREPOTEST");

            // Assert
            Assert.IsInstanceOfType(result, typeof(Retrieval));
        }
        public void TestCleanup()
        {
            Retrieval retrieval = context.Retrieval.Where(x => x.RetrievalId == "TEST").First();

            List <StockMovement> smlist = context.StockMovement.Where(x => x.DisbursementId == "TEST").ToList();

            foreach (StockMovement sm in smlist)
            {
                stockmovementRepository.Delete(sm);
            }


            List <Disbursement> list = disbursementService.FindDisbursementsByRetrievalId(retrieval.RetrievalId);

            foreach (Disbursement d in list)
            {
                //Delete dummy disbursement test objects
                disbursementRepository.Delete(d);
            }

            //delete retrieval objects
            retrievalRepository.Delete(retrieval);

            var requisitionRepository = new RequisitionRepository(context);

            if (disbursementRepository.ExistsById("RSERVICETEST"))
            {
                disbursementRepository.Delete(disbursementRepository.FindById("RSERVICETEST"));
            }
            if (disbursementRepository.ExistsById("RSERVICETEST1"))
            {
                disbursementRepository.Delete(disbursementRepository.FindById("RSERVICETEST1"));
            }
            if (disbursementRepository.ExistsById("RSERVICETEST2"))
            {
                disbursementRepository.Delete(disbursementRepository.FindById("RSERVICETEST2"));
            }
            if (requisitionRepository.ExistsById("RSERVICETEST"))
            {
                requisitionRepository.Delete(requisitionRepository.FindById("RSERVICETEST"));
            }
            if (requisitionRepository.ExistsById("RSERVICETEST1"))
            {
                requisitionRepository.Delete(requisitionRepository.FindById("RSERVICETEST1"));
            }
            if (requisitionRepository.ExistsById("RSERVICETEST2"))
            {
                requisitionRepository.Delete(requisitionRepository.FindById("RSERVICETEST2"));
            }
            if (retrievalRepository.ExistsById("RSERVICETEST"))
            {
                retrievalRepository.Delete(retrievalRepository.FindById("RSERVICETEST"));
            }
            if (requisitionRepository.FindAll().Where(r => r.EmployeeRemarks.Contains("RSERVICETEST")).Count() > 0)
            {
                requisitionRepository.Delete(requisitionRepository.FindAll().Where(r => r.EmployeeRemarks.Contains("RSERVICETEST")).FirstOrDefault());
            }
        }
        public void TestCleanup()
        {
            Retrieval retrieval = context.Retrieval.Where(x => x.RetrievalId == "TEST").First();

            List <Disbursement> list = disbursementService.FindDisbursementsByRetrievalId(retrieval.RetrievalId);

            foreach (Disbursement d in list)
            {
                //Delete dummy disbursement test objects
                disbursementRepository.Delete(d);
            }

            //have to delete requisitions before retrievals
            List <Requisition> requisitionlist = context.Requisition.Where(x => x.RequisitionId == "TEST").ToList();

            foreach (Requisition r in requisitionlist)
            {
                //delete dummy requisition test objects
                requisitionRepository.Delete(r);
            }

            List <Requisition> requisitionlist2 = context.Requisition.Where(x => x.RequisitionId == "TEST2").ToList();

            foreach (Requisition r in requisitionlist2)
            {
                //delete dummy requisition test objects
                requisitionRepository.Delete(r);
            }

            //delete retrieval objects
            retrievalRepository.Delete(retrieval);
            //}

            if (disbursementRepository.ExistsById("COLLECTIONTEST"))
            {
                disbursementRepository.Delete(disbursementRepository.FindById("COLLECTIONTEST"));
            }
            if (disbursementRepository.ExistsById("DSERVICETEST"))
            {
                disbursementRepository.Delete(disbursementRepository.FindById("DSERVICETEST"));
            }
            if (requisitionRepository.ExistsById("DSERVICETEST"))
            {
                requisitionRepository.Delete(requisitionRepository.FindById("DSERVICETEST"));
            }
            if (retrievalRepository.ExistsById("DSERVICETEST"))
            {
                retrievalRepository.Delete(retrievalRepository.FindById("DSERVICETEST"));
            }
        }
 public void TestCleanup()
 {
     if (disbursementRepository.ExistsById("DAPICONTROLTEST"))
     {
         disbursementRepository.Delete(disbursementRepository.FindById("DAPICONTROLTEST"));
     }
     if (requisitionRepository.ExistsById("DAPICONTROLTEST"))
     {
         requisitionRepository.Delete(requisitionRepository.FindById("DAPICONTROLTEST"));
     }
     if (retrievalRepository.ExistsById("DAPICONTROLTEST"))
     {
         retrievalRepository.Delete(retrievalRepository.FindById("DAPICONTROLTEST"));
     }
 }
Пример #6
0
        public void TestCleanup()
        {
            var disbursementRepository = new DisbursementRepository(context);
            var retrievalRepository    = new RetrievalRepository(context);
            var requisitionRepository  = new RequisitionRepository(context);

            if (requisitionRepository.ExistsById("RETCONTROLTEST"))
            {
                requisitionRepository.Delete(requisitionRepository.FindById("RETCONTROLTEST"));
            }
            if (disbursementRepository.ExistsById("RETCONTROLTEST"))
            {
                disbursementRepository.Delete(disbursementRepository.FindById("RETCONTROLTEST"));
            }
            if (retrievalRepository.ExistsById("RETCONTROLTEST"))
            {
                retrievalRepository.Delete(retrievalRepository.FindById("RETCONTROLTEST"));
            }
        }
        public void TestCleanup()
        {
            var usedNotificationId = IdService.GetNewNotificationId(context) - 1;

            if (notificationRepository.ExistsById(usedNotificationId))
            {
                notificationRepository.Delete(notificationRepository.FindById(usedNotificationId));
            }


            //delete test object from Disbursements
            List <Disbursement> ddlist = context.Disbursement.Where(x => x.DisbursementId == "TEST").ToList();

            foreach (Disbursement dd in ddlist)
            {
                disbursementRepository.Delete(dd);
            }

            //delete test object from Requisitions
            List <Requisition> rlist = context.Requisition.Where(x => x.RequisitionId == "TEST").ToList();

            foreach (Requisition r in rlist)
            {
                requisitionRepository.Delete(r);
            }

            //delete test object from StockAdjustments
            List <StockAdjustment> salist = context.StockAdjustment.Where(x => x.StockAdjustmentId == "TEST").ToList();

            foreach (StockAdjustment SA in salist)
            {
                saRepository.Delete(SA);
            }

            var retrievalRepository = new RetrievalRepository(context);

            if (retrievalRepository.ExistsById("NOTIFICATIONTEST"))
            {
                retrievalRepository.Delete(retrievalRepository.FindById("NOTIFICATIONTEST"));
            }
        }
Пример #8
0
 public Retrieval FindRetrievalById(string id)
 {
     return(retrievalRepository.FindById(id));
 }
        public void TestInitialize()
        {
            context = new ApplicationDbContext();
            disbursementRepository       = new DisbursementRepository(context);
            disbursementdetailRepository = new DisbursementDetailRepository(context);
            disbursementService          = new DisbursementService(context);
            itemRepository              = new ItemRepository(context);
            retrievalRepository         = new RetrievalRepository(context);
            requisitionRepository       = new RequisitionRepository(context);
            requisitiondetailRepository = new RequisitionDetailRepository(context);
            departmentRepository        = new DepartmentRepository(context);

            Retrieval retrieval = new Retrieval();

            if (retrievalRepository.FindById("TEST") == null)
            {
                //save retrieval object into db

                retrieval.RetrievalId     = "TEST";
                retrieval.CreatedDateTime = DateTime.Now;
                retrievalRepository.Save(retrieval);
            }
            else
            {
                retrieval = retrievalRepository.FindById("TEST");
            }

            //save disbursement object into db

            Disbursement disbursement = new Disbursement();

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

            disbursementRepository.Save(disbursement);

            //save disbursement detail object into db
            DisbursementDetail detail = new DisbursementDetail()
            {
                Disbursement   = disbursement,
                Item           = context.Item.First(),
                PlanQuantity   = 20,
                ActualQuantity = 20
            };

            disbursementdetailRepository.Save(detail);

            Requisition requisition = new Requisition()
            {
                RequisitionId   = "TEST",
                Retrieval       = retrieval,
                CreatedDateTime = DateTime.Now,
                Status          = new StatusService(context).FindStatusByStatusId(8)
            };

            requisitionRepository.Save(requisition);
        }