public void Creates_new_tblPackSch_record_and_KillSwitch_will_not_have_been_engaged_if_service_method_and_synchronization_were_successful()
            {
                //Arrange
                var workType = RVCUnitOfWork.WorkTypeRepository.All().FirstOrDefault();

                if (workType == null)
                {
                    throw new Exception("No WorkType record found.");
                }

                var chileProduct = RVCUnitOfWork.ChileProductRepository.All().FirstOrDefault();

                if (chileProduct == null)
                {
                    throw new Exception("No ChileProduct record found.");
                }

                var packagingProduct = RVCUnitOfWork.PackagingProductRepository.All().FirstOrDefault(p => p.Weight > 0.0f);

                if (packagingProduct == null)
                {
                    throw new Exception("No PackagingProduct record found.");
                }

                var productionLine = RVCUnitOfWork.LocationRepository.All().FirstOrDefault(l => l.LocationType == LocationType.ProductionLine);

                if (productionLine == null)
                {
                    throw new Exception("No ProductionLocation of Line type found.");
                }

                var parameters = new CreatePackScheduleParameters
                {
                    UserToken               = TestUser.UserName,
                    WorkTypeKey             = new WorkTypeKey(workType),
                    ChileProductKey         = new ChileProductKey(chileProduct),
                    PackagingProductKey     = new PackagingProductKey(packagingProduct),
                    ProductionLineKey       = new LocationKey(productionLine),
                    SummaryOfWork           = "SynchTest",
                    ProductionDeadline      = new DateTime(2020, 2, 20),
                    ScheduledProductionDate = DateTime.UtcNow,
                    BatchTargetWeight       = 1000,
                    BatchTargetAsta         = 1,
                    BatchTargetScan         = 2,
                    BatchTargetScoville     = 3
                };

                TestHelper.ResetContext();

                //Act
                var result        = Service.CreatePackSchedule(parameters);
                var packSchString = GetKeyFromConsoleString(ConsoleOutput.AddedPackSchedule);

                //Assert
                result.AssertSuccess();
                MockKillSwitch.Verify(k => k.Engage(), Times.Never());

                var packSchId = SynchronizePackScheduleHelper.ToPackSchId(packSchString).Value;

                Assert.IsNotNull(new RioAccessSQLEntities().tblPackSches.FirstOrDefault(p => p.PackSchID == packSchId));
            }
            public void Preserves_supplied_PackSchedule_key_and_PSNum()
            {
                //Arrange
                var workType = RVCUnitOfWork.WorkTypeRepository.All().FirstOrDefault();

                if (workType == null)
                {
                    throw new Exception("No WorkType record found.");
                }

                var chileProduct = RVCUnitOfWork.ChileProductRepository.All().FirstOrDefault();

                if (chileProduct == null)
                {
                    throw new Exception("No ChileProduct record found.");
                }

                var packagingProduct = RVCUnitOfWork.PackagingProductRepository.All().FirstOrDefault(p => p.Weight > 0.0f);

                if (packagingProduct == null)
                {
                    throw new Exception("No PackagingProduct record found.");
                }

                var productionLine = RVCUnitOfWork.LocationRepository.All().FirstOrDefault(l => l.LocationType == LocationType.ProductionLine);

                if (productionLine == null)
                {
                    throw new Exception("No ProductionLocation of Line type found.");
                }

                var dateCreated = new DateTime(2017, 1, 1);
                var sequence    = 123;
                var psNum       = 312;

                var parameters = new CreatePackScheduleParameters
                {
                    UserToken               = TestUser.UserName,
                    WorkTypeKey             = new WorkTypeKey(workType),
                    ChileProductKey         = new ChileProductKey(chileProduct),
                    PackagingProductKey     = new PackagingProductKey(packagingProduct),
                    ProductionLineKey       = new LocationKey(productionLine),
                    SummaryOfWork           = "SynchTest",
                    ProductionDeadline      = new DateTime(2020, 2, 20),
                    ScheduledProductionDate = DateTime.UtcNow,
                    BatchTargetWeight       = 1000,
                    BatchTargetAsta         = 1,
                    BatchTargetScan         = 2,
                    BatchTargetScoville     = 3,

                    DateCreated = dateCreated,
                    Sequence    = sequence,
                    PSNum       = psNum
                };

                TestHelper.ResetContext();

                //Act
                var result = Service.CreatePackSchedule(parameters);

                //Assert
                result.AssertSuccess();
                var packSchedule = TestHelper.Context.PackSchedules.FirstOrDefault(p => p.DateCreated == dateCreated && p.SequentialNumber == sequence);

                Assert.AreEqual(psNum, packSchedule.PSNum);
            }