public void SaveAndDeleteTestNew()
        {
            // Save new object into DB
            // Arrange
            var stockAdjustment = new StockAdjustment
            {
                StockAdjustmentId = "DOREPOTEST",
                CreatedDateTime   = DateTime.Now
            };

            // Act
            var saveResult = stockAdjustmentRepository.Save(stockAdjustment);

            // Assert
            Assert.IsInstanceOfType(saveResult, typeof(StockAdjustment));

            // Delete saved object from DB
            // Act
            stockAdjustmentRepository.Delete(saveResult);

            // Assert
            Assert.IsNull(stockAdjustmentRepository.FindById("DOREPOTEST"));
        }
        public void TestCleanUp()
        {
            var stockAdjustmentRepository = new StockAdjustmentRepository(context);

            if (saService.FindAllStockAdjustment().Where(x => x.Remarks == "THIS IS A TEST").FirstOrDefault() != null)
            {
                saRepository.Delete(saService.FindAllStockAdjustment().Where(x => x.Remarks == "THIS IS A TEST").FirstOrDefault());
            }

            if (stockAdjustmentRepository.ExistsById("ADJCONTROLTEST"))
            {
                stockAdjustmentRepository.Delete(stockAdjustmentRepository.FindById("ADJCONTROLTEST"));
            }
        }
Exemplo n.º 3
0
        public void TestCleanup()
        {
            if (stockAdjustmentDetailRepository.ExistsById("SADREPOTEST", "E030"))
            {
                stockAdjustmentDetailRepository.Delete(stockAdjustmentDetailRepository.FindById("SADREPOTEST", "E030"));
            }

            if (stockAdjustmentDetailRepository.ExistsById("SADREPOTEST", "P030"))
            {
                stockAdjustmentDetailRepository.Delete(stockAdjustmentDetailRepository.FindById("SADREPOTEST", "P030"));
            }

            if (stockAdjustmentRepository.ExistsById("SADREPOTEST"))
            {
                stockAdjustmentRepository.Delete(stockAdjustmentRepository.FindById("SADREPOTEST"));
            }
        }
        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"));
            }
        }
        public void TestCleanUp()
        {
            StockMovement a = context.StockMovement.Where(x => x.StockMovementId == 1).First();

            //Revert edit object
            a.DisbursementId = null;
            stockmovementService.Save(a);

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

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

            List <Disbursement> ddlist = context.Disbursement.Where(x => x.DisbursementId == "TEST").ToList();

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

            List <DeliveryOrder> dolist = context.DeliveryOrder.Where(x => x.DeliveryOrderNo == "TEST").ToList();

            foreach (DeliveryOrder d in dolist)
            {
                doRepository.Delete(d);
            }

            List <StockAdjustment> salist = context.StockAdjustment.Where(x => x.StockAdjustmentId == "TEST").ToList();

            foreach (StockAdjustment SA in salist)
            {
                saRepository.Delete(SA);
            }
        }
        public void CreateDraftStockAdjustmentTest()
        {
            //Arrange
            StockAdjustment expect = new StockAdjustment();
            //Random rd = new Random();
            //int i = rd.Next();
            string id = "he01";

            expect.StockAdjustmentId = id;
            expect.CreatedDateTime   = DateTime.Now;
            // Act
            try
            {
                var result = service.CreateDraftStockAdjustment(expect);
                Assert.AreEqual(3, result.Status.StatusId);
                stockAdjustmentRepository.Delete(expect);
            }
            catch (Exception e)
            {
                Assert.IsTrue(e.Message.Contains("can't find such status"));
            }
        }
 public void TestClean()
 {
     saRepository.Delete(saRepository.FindById("he01"));
 }
        public void SaveFromMobileTest()
        {
            //Arrange
            //Instantiate controller

            StockAdjustmentAPIController controller = new StockAdjustmentAPIController()
            {
                CurrentUserName = "******",
                Context         = this.context
            };

            controller.ModelState.Clear();

            Item item = context.Item.First();

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

            MobileSADViewModel VM = new MobileSADViewModel()
            {
                ItemCode         = item.ItemCode,
                UserName         = "******",
                OriginalQuantity = "5",
                AfterQuantity    = "6",

                Reason = "API Controller TEST"
            };

            list.Add(VM);
            //Act
            IHttpActionResult actionResult = controller.Save(list);
            var contentResult = actionResult as OkNegotiatedContentResult <String>;

            //Assert
            Assert.IsNotNull(actionResult);
            Assert.IsNotNull(contentResult.Content);

            //Delete
            saRepository.Delete(saRepository.FindById(contentResult.Content));
        }
Exemplo n.º 9
0
        public void TestCleanup()
        {
            // Delete DeliveryOrders
            var deliveryOrderRepository = new DeliveryOrderRepository(context);

            if (deliveryOrderRepository.FindAll().Where(x => x.InvoiceFileName == "IDSERVICETEST").Count() > 0)
            {
                deliveryOrderRepository.FindAll().Where(x => x.InvoiceFileName == "IDSERVICETEST").ToList().ForEach(x => deliveryOrderRepository.Delete(x));
            }

            // Delete Disbursements
            var disbursementRepository = new DisbursementRepository(context);

            if (disbursementRepository.FindAll().Where(x => x.Remarks == "IDSERVICETEST").Count() > 0)
            {
                disbursementRepository.FindAll().Where(x => x.Remarks == "IDSERVICETEST").ToList().ForEach(x => disbursementRepository.Delete(x));
            }

            // Delete Purchase Orders
            var purchaseOrderRepository = new PurchaseOrderRepository(context);

            if (purchaseOrderRepository.FindAll().Where(x => x.Status.StatusId == 16).Count() > 0)
            {
                purchaseOrderRepository.FindAll().Where(x => x.Status.StatusId == 16).ToList().ForEach(x => purchaseOrderRepository.Delete(x));
            }

            // Delete Requisitions
            var requisitionRepository = new RequisitionRepository(context);

            if (requisitionRepository.FindAll().Where(x => x.EmployeeRemarks == "IDSERVICETEST").Count() > 0)
            {
                requisitionRepository.FindAll().Where(x => x.EmployeeRemarks == "IDSERVICETEST").ToList().ForEach(x => requisitionRepository.Delete(x));
            }

            // Delete Retrievals
            var retrievalRepository = new RetrievalRepository(context);

            if (retrievalRepository.FindAll().Where(x => x.Status.StatusId == 16).Count() > 0)
            {
                retrievalRepository.FindAll().Where(x => x.Status.StatusId == 16).ToList().ForEach(x => retrievalRepository.Delete(x));
            }

            // Delete StockAdjustments
            var stockAdjustmentRepository = new StockAdjustmentRepository(context);

            if (stockAdjustmentRepository.FindAll().Where(x => x.Remarks == "IDSERVICETEST").Count() > 0)
            {
                stockAdjustmentRepository.FindAll().Where(x => x.Remarks == "IDSERVICETEST").ToList().ForEach(x => stockAdjustmentRepository.Delete(x));
            }
        }