public void FindDisbursementsByRetrievalIdTest()
        {
            //Arrange
            //get retrival object
            Retrieval retrieval = context.Retrieval.Where(x => x.RetrievalId == "TEST").First();

            //save 2 disbursement objects
            Disbursement a = new Disbursement();

            a.DisbursementId  = IdService.GetNewDisbursementId(context);
            a.Retrieval       = retrieval;
            a.CreatedDateTime = DateTime.Now;
            disbursementService.Save(a);

            Disbursement b = new Disbursement();

            b.DisbursementId  = IdService.GetNewDisbursementId(context);
            b.Retrieval       = retrieval;
            b.CreatedDateTime = DateTime.Now;
            disbursementService.Save(b);

            //find any existing data in disbursement where RetrievalId = TESTER and add 2 more
            int expected = context.Disbursement.Where(x => x.Retrieval.RetrievalId == "TEST").Count();

            //Act
            var result = disbursementService.FindDisbursementsByRetrievalId(retrieval.RetrievalId).Count;

            //Assert
            Assert.AreEqual(expected, result);

            //Delete dummy test objects in TestCleanUp
        }
Пример #2
0
        public void GetNewDisbursementId_ExistingId_Valid()
        {
            // Arrange
            string expectedPrefix = $"DSB-{DateTime.Now.Year}{DateTime.Now.Month:00}";
            var    previous       = IdService.GetNewDisbursementId(context);

            new DisbursementRepository(context).Save(new Disbursement()
            {
                DisbursementId  = previous,
                Remarks         = "IDSERVICETEST",
                CreatedDateTime = DateTime.Now.AddDays(1 - DateTime.Today.Day),
            });

            // Act
            var current = IdService.GetNewDisbursementId(context);

            new DisbursementRepository(context).Save(new Disbursement()
            {
                DisbursementId  = current,
                Remarks         = "IDSERVICETEST",
                CreatedDateTime = DateTime.Now,
            });
            var previousSerialNoParseResult = Int32.TryParse(previous.Substring(previous.Length - 3), out int previousSerialNo);
            var resultSerialNoParseResult   = Int32.TryParse(current.Substring(current.Length - 3), out int resultSerialNo);

            // Assert
            Assert.AreEqual(1, resultSerialNo - previousSerialNo);
        }
Пример #3
0
        public void GetNewDisbursementIdTest()
        {
            // Arrange
            string expectedPrefix = $"DSB-{DateTime.Now.Year}{DateTime.Now.Month:00}";

            // Act
            var result = IdService.GetNewDisbursementId(context);
            var serialNoParseResult = Int32.TryParse(result.Substring(result.Length - 3), out int serialNo);

            // Assert
            Assert.AreEqual(expectedPrefix, result.Substring(0, 10));
            Assert.IsTrue(serialNoParseResult);
        }
        public void SaveTest()
        {
            //Arrange
            Disbursement newDisbursement = new Disbursement();

            newDisbursement.DisbursementId  = IdService.GetNewDisbursementId(context);
            newDisbursement.CreatedDateTime = DateTime.Now;
            string expected = newDisbursement.DisbursementId;

            //Act
            var result = disbursementService.Save(newDisbursement);

            disbursementRepository.Delete(newDisbursement);
            //Assert
            Assert.AreEqual(expected, result.DisbursementId);
        }
        public void ConfirmCollectionTest()
        {
            int expected = 10; //status id of Items Collected

            //get retrieval object
            Retrieval retrieval = context.Retrieval.Where(x => x.RetrievalId == "TEST").First();

            retrieval.Requisitions.FirstOrDefault().RequisitionDetails = new List <RequisitionDetail>()
            {
                new RequisitionDetail()
                {
                    RequisitionId = retrieval.Requisitions.FirstOrDefault().RequisitionId,
                    Item          = new ItemService(context).FindItemByItemCode("E030"),
                    Status        = new StatusService(context).FindStatusByStatusId(8),
                }
            };

            //create disbursement and save it into database
            Disbursement a = new Disbursement();

            a.DisbursementId = IdService.GetNewDisbursementId(context);
            a.Department     = departmentRepository.FindById("COMM");
            retrieval.Requisitions.Add(context.Requisition.First());
            a.Retrieval       = retrieval;
            a.CreatedDateTime = DateTime.Now;
            disbursementService.Save(a);

            //include Disbursement detail object and save it
            DisbursementDetail detail = new DisbursementDetail()
            {
                Disbursement   = a,
                Item           = context.Item.First(),
                PlanQuantity   = 1,
                ActualQuantity = 1
            };

            disbursementdetailRepository.Save(detail);

            Disbursement result = disbursementService.ConfirmCollection(a.DisbursementId);


            //Asert
            Assert.AreEqual(expected, result.Status.StatusId);
        }
        public void FindStockMovementByDisbursementIdTest()
        {
            //Arrange
            //Persist a dummy data object
            StockMovement a = new StockMovement();

            a.CreatedDateTime = DateTime.Now;
            a.DisbursementId  = IdService.GetNewDisbursementId(context);
            a.Item            = context.Item.First();
            stockmovementService.Save(a);

            int expected = context.StockMovement.Where(x => x.DisbursementId == a.DisbursementId).ToList().Count;

            //Act
            var result = stockmovementService.FindStockMovementByDisbursementId(a.DisbursementId).Count;

            stockmovementRepository.Delete(a);

            //Assert
            Assert.AreEqual(expected, result);
        }