public void RejectStockAdjustmentMobile_AlreadyApproved_ThrowsException() { // Arrange var stockAdjustmentRepository = new StockAdjustmentRepository(context); var stockAdjustmentService = new StockAdjustmentService(context); var stockAdjustment = stockAdjustmentRepository.Save(new StockAdjustment() { StockAdjustmentId = "ADJAPPROVETEST", CreatedBy = new UserService(context).FindUserByEmail("*****@*****.**"), CreatedDateTime = DateTime.Now, Status = new StatusService(context).FindStatusByStatusId(6), StockAdjustmentDetails = new List <StockAdjustmentDetail>() { new StockAdjustmentDetail() { StockAdjustmentId = "ADJAPPROVETEST", ItemCode = "E030", Item = new ItemService(context).FindItemByItemCode("E030"), OriginalQuantity = 10, AfterQuantity = 10, } } }); // Act stockAdjustmentService.RejectStockAdjustment("ADJAPPROVETEST", "*****@*****.**"); }
public void RejectStockAdjustmentMobile_Valid() { // Arrange var stockAdjustmentRepository = new StockAdjustmentRepository(context); var stockAdjustmentService = new StockAdjustmentService(context); var stockAdjustment = stockAdjustmentRepository.Save(new StockAdjustment() { StockAdjustmentId = "ADJAPPROVETEST", CreatedBy = new UserService(context).FindUserByEmail("*****@*****.**"), CreatedDateTime = DateTime.Now, Status = new StatusService(context).FindStatusByStatusId(4), StockAdjustmentDetails = new List <StockAdjustmentDetail>() { new StockAdjustmentDetail() { StockAdjustmentId = "ADJAPPROVETEST", ItemCode = "E030", Item = new ItemService(context).FindItemByItemCode("E030"), OriginalQuantity = 10, AfterQuantity = 10, } } }); // Act stockAdjustmentService.RejectStockAdjustment("ADJAPPROVETEST", "*****@*****.**"); // Assert Assert.AreEqual(5, stockAdjustment.Status.StatusId); Assert.IsTrue(new StockMovementRepository(context).FindByStockAdjustmentId("ADJAPPROVETEST").FirstOrDefault() == null); }
public void TestInitialize() { context = new ApplicationDbContext(); statusRepository = new StatusRepository(context); saRepository = new StockAdjustmentRepository(context); userRepository = new UserRepository(context); //Create a draft stockadjustment StockAdjustment sa1 = new StockAdjustment(); sa1.StockAdjustmentId = "he01"; sa1.CreatedDateTime = DateTime.Now; sa1.Status = statusRepository.FindById(3); sa1.CreatedBy = userRepository.FindByEmail("*****@*****.**"); sa1.ApprovedBySupervisor = userRepository.FindByEmail("*****@*****.**"); StockAdjustmentDetail s1 = new StockAdjustmentDetail(); s1.StockAdjustmentId = "he01"; s1.ItemCode = "C002"; s1.OriginalQuantity = 10; s1.AfterQuantity = 20; StockAdjustmentDetail s2 = new StockAdjustmentDetail(); s2.StockAdjustmentId = "he01"; s2.ItemCode = "C003"; s2.OriginalQuantity = 20; s2.AfterQuantity = 30; List <StockAdjustmentDetail> list = new List <StockAdjustmentDetail>(); list.Add(s1); list.Add(s2); sa1.StockAdjustmentDetails = list; saRepository.Save(sa1); }
public void FindByIdTestNotNull() { // Arrange var expected = new StockAdjustmentDetail() { StockAdjustmentId = "SADREPOTEST", ItemCode = "E030", }; stockAdjustmentRepository.Save(new StockAdjustment() { StockAdjustmentId = "SADREPOTEST", CreatedDateTime = DateTime.Now, }); stockAdjustmentDetailRepository.Save(expected); // Act var result = stockAdjustmentDetailRepository.FindById("SADREPOTEST", "E030"); // Assert Assert.IsInstanceOfType(result, typeof(StockAdjustmentDetail)); }
public void GetAllStockadjustment_ContainResult() { //Arrange //Instantiate controller var controller = new StockAdjustmentAPIController(); StockAdjustment sa1 = new StockAdjustment(); sa1.StockAdjustmentId = "he01"; sa1.Remarks = "THIS IS A TEST"; sa1.CreatedDateTime = DateTime.Now; sa1.Status = statusRepository.FindById(3); StockAdjustmentDetail s1 = new StockAdjustmentDetail(); s1.StockAdjustmentId = "he01"; s1.ItemCode = "C001"; s1.OriginalQuantity = 10; s1.AfterQuantity = 20; StockAdjustmentDetail s2 = new StockAdjustmentDetail(); s2.StockAdjustmentId = "he01"; s2.ItemCode = "C002"; s2.OriginalQuantity = 20; s2.AfterQuantity = 30; List <StockAdjustmentDetail> list = new List <StockAdjustmentDetail>(); list.Add(s1); list.Add(s2); sa1.StockAdjustmentDetails = list; saRepository.Save(sa1); //Act StockAdjustmentViewModel result = controller.GetAllStockAdjustments().OrderByDescending (x => x.CreatedDateTime).First(); //Assert Assert.AreEqual(sa1.StockAdjustmentId, result.StockAdjustmentId); saRepository.Delete(saRepository.FindById("he01")); }
public void FindByIdTestNotNull() { // Arrange stockAdjustmentRepository.Save(new StockAdjustment() { StockAdjustmentId = "DOREPOTEST", CreatedDateTime = DateTime.Now, }); // Act var result = stockAdjustmentRepository.FindById("DOREPOTEST"); // Assert Assert.IsInstanceOfType(result, typeof(StockAdjustment)); }
public void TestInitialize() { context = new ApplicationDbContext(); notificationRepository = new NotificationRepository(context); notificationService = new NotificationService(context); disbursementRepository = new DisbursementRepository(context); saRepository = new StockAdjustmentRepository(context); requisitionRepository = new RequisitionRepository(context); var retrieval = new RetrievalRepository(context).Save(new Retrieval() { RetrievalId = "NOTIFICATIONTEST", CreatedDateTime = DateTime.Now, }); //save new disbursement object into db Disbursement disbursement = new Disbursement(); if (disbursementRepository.FindById("TEST") == null) { disbursement.Department = new DepartmentRepository(context).FindById("ENGL"); disbursement.DisbursementId = "TEST"; disbursement.CreatedDateTime = DateTime.Now; disbursement.Retrieval = retrieval; disbursement.DisbursementDetails = new List <DisbursementDetail>() { new DisbursementDetail() { DisbursementId = "TEST", Item = new ItemService(context).FindItemByItemCode("E030"), ActualQuantity = 20, } }; } else { disbursement = disbursementRepository.FindById("TEST"); } disbursementRepository.Save(disbursement); //save new requisition object into db Requisition requisition = new Requisition(); if (requisitionRepository.FindById("TEST") == null) { requisition.Department = new DepartmentRepository(context).FindById("ENGL"); requisition.RequisitionId = "TEST"; requisition.CreatedDateTime = DateTime.Now; requisition.Retrieval = retrieval; requisition.RequisitionDetails = new List <RequisitionDetail>() { new RequisitionDetail() { RequisitionId = "TEST", Item = new ItemService(context).FindItemByItemCode("E030"), Status = new StatusService(context).FindStatusByStatusId(8), } }; } else { requisition = requisitionRepository.FindById("TEST"); } requisitionRepository.Save(requisition); //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 StockAdjustment with status: draft public StockAdjustment CreateDraftStockAdjustment(StockAdjustment stockadjustment) { //controller pass stockadjustment to the method stockadjustment.Status = statusRepository.FindById(3); stockAdjustmentRepository.Save(stockadjustment); return(stockadjustment); }
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); }