public void Updates_associated_batch_tblLot_records_Company_IA_column_as_expected() { //Arrange var customer = RVCUnitOfWork.CustomerRepository.Filter(c => true, c => c.Company).FirstOrDefault(); if (customer == null) { Assert.Inconclusive("No Customer records loaded."); } var packSchedule = RVCUnitOfWork.PackScheduleRepository .Filter(p => p.ProductionBatches.Count > 2 && p.ProductionBatches.All(b => b.Production.PickedInventory.Items.Any()) && p.CustomerId != customer.Id, p => p.ProductionBatches).FirstOrDefault(); if (packSchedule == null) { Assert.Inconclusive("No valid test PackSchedule found."); } var parameters = new UpdatePackScheduleParameters { UserToken = TestUser.UserName, PackScheduleKey = new PackScheduleKey(packSchedule), WorkTypeKey = new WorkTypeKey(packSchedule), ChileProductKey = new ChileProductKey(packSchedule), PackagingProductKey = new PackagingProductKey(packSchedule), ScheduledProductionDate = packSchedule.ScheduledProductionDate, ProductionDeadline = packSchedule.ProductionDeadline, ProductionLineKey = new LocationKey(packSchedule), SummaryOfWork = packSchedule.SummaryOfWork, CustomerKey = new CompanyKey(customer), OrderNumber = packSchedule.OrderNumber, BatchTargetWeight = packSchedule.DefaultBatchTargetParameters.BatchTargetWeight, BatchTargetAsta = packSchedule.DefaultBatchTargetParameters.BatchTargetAsta, BatchTargetScan = packSchedule.DefaultBatchTargetParameters.BatchTargetScan, BatchTargetScoville = packSchedule.DefaultBatchTargetParameters.BatchTargetScoville, }; //Act var result = Service.UpdatePackSchedule(parameters); //Assert result.AssertSuccess(); var packSchId = SynchronizePackScheduleHelper.ToPackSchId(GetKeyFromConsoleString(ConsoleOutput.UpdatedPackSchedule)).Value; using (var oldContext = new RioAccessSQLEntities()) { var tblLots = oldContext.tblLots.Where(l => l.PackSchID == packSchId).ToList(); Assert.Greater(tblLots.Count, 2); foreach (var lot in tblLots) { Assert.AreEqual(customer.Company.Name, lot.Company_IA); } } }
public HttpResponseMessage Put(string id, UpdatePackScheduleParameters values) { if (!ModelState.IsValid) { return(new HttpResponseMessage(HttpStatusCode.BadRequest) { ReasonPhrase = ModelState.GetErrorSummary() }); } values.PackScheduleKey = id; var parameters = values.Map().To <UpdatePackScheduleParameters>(); _userIdentityProvider.SetUserIdentity(parameters); return(_productionService.UpdatePackSchedule(parameters).ToHttpResponseMessage()); }
public void Updates_tblPackSch_record_and_KillSwitch_will_not_have_been_engaged_if_service_method_and_syncrhonization_were_successful() { //Arrange const string expectedSummary = "UpdatePackScheduleSynchTest"; var packSchedule = RVCUnitOfWork.PackScheduleRepository.All().FirstOrDefault(p => p.SummaryOfWork != expectedSummary); if (packSchedule == null) { throw new Exception("No valid test PackSchedule found."); } var parameters = new UpdatePackScheduleParameters { PackScheduleKey = new PackScheduleKey(packSchedule), UserToken = TestUser.UserName, ScheduledProductionDate = packSchedule.ScheduledProductionDate, ProductionDeadline = packSchedule.ProductionDeadline, ProductionLineKey = new LocationKey(packSchedule), SummaryOfWork = expectedSummary, ChileProductKey = new ChileProductKey(packSchedule), PackagingProductKey = new PackagingProductKey(packSchedule), WorkTypeKey = new WorkTypeKey(packSchedule), }; parameters.SetBatchTargetParameters(packSchedule.DefaultBatchTargetParameters); TestHelper.ResetContext(); //Act var result = Service.UpdatePackSchedule(parameters); var packSchString = GetKeyFromConsoleString(ConsoleOutput.UpdatedPackSchedule); //Assert result.AssertSuccess(); MockKillSwitch.Verify(k => k.Engage(), Times.Never()); var packSchId = SynchronizePackScheduleHelper.ToPackSchId(packSchString).Value; Assert.AreEqual(expectedSummary, new RioAccessSQLEntities().tblPackSches.FirstOrDefault(p => p.PackSchID == packSchId).PackSchDesc); }