public void Creates_new_tblIncoming_records_and_KillSwitch_will_not_have_been_engaged_on_success()
            {
                //Arrange
                var unfinishedBatch = GetUnfinishedBatch();

                var productionLine = RVCUnitOfWork.LocationRepository.Filter(l => l.LocationType == LocationType.ProductionLine).First();
                var packaging      = RVCUnitOfWork.PackagingProductRepository.All().First(p => p.Weight > 0);
                var destinations   = RVCUnitOfWork.LocationRepository.Filter(l => l.LocationType == LocationType.Warehouse).Take(2).ToList();
                var treatment      = RVCUnitOfWork.InventoryTreatmentRepository.All().First();

                const int quantity0  = 100;
                const int quantity1  = 101;
                var       now        = DateTime.Now;
                var       parameters = new CreateProductionBatchResultsParameters
                {
                    UserToken                = TestUser.UserName,
                    ProductionBatchKey       = new LotKey(unfinishedBatch),
                    ProductionLineKey        = new LocationKey(productionLine),
                    ProductionShiftKey       = "SHIFTTEST",
                    ProductionStartTimestamp = new DateTime(2014, 1, 1, now.Hour, now.Minute, now.Second, now.Millisecond),
                    ProductionEndTimestamp   = new DateTime(2014, 1, 2, now.Hour, now.Minute, now.Second, now.Millisecond),
                    InventoryItems           = new[]
                    {
                        new BatchResultItemParameters
                        {
                            PackagingProduct   = packaging,
                            Location           = destinations[0],
                            InventoryTreatment = treatment,
                            Quantity           = quantity0
                        },
                        new BatchResultItemParameters
                        {
                            PackagingProduct   = packaging,
                            Location           = destinations[1],
                            InventoryTreatment = treatment,
                            Quantity           = quantity1
                        }
                    }
                };

                //Act
                var result    = Service.CreateProductionBatchResults(parameters);
                var lotString = GetKeyFromConsoleString(ConsoleOutput.SyncProductionResults);

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

                var newLot = int.Parse(lotString);

                using (var context = new RioAccessSQLEntities())
                {
                    var tblLot = context.tblLots.Where(a => a.Lot == newLot).Select(l => new
                    {
                        lot       = l,
                        incomings = l.tblIncomings
                    }).FirstOrDefault();
                    Assert.IsNotNull(tblLot);
                    Assert.IsNotNull(tblLot.incomings.FirstOrDefault(i => i.Quantity == quantity0));
                    Assert.IsNotNull(tblLot.incomings.FirstOrDefault(i => i.Quantity == quantity1));
                }
            }
            public void Sets_tblLot_LotStat_field_as_expected_on_success()
            {
                //Arrange
                var unfinishedBatch = GetUnfinishedBatch();

                var productionLine = RVCUnitOfWork.LocationRepository.Filter(l => l.LocationType == LocationType.ProductionLine).First();
                var packaging      = RVCUnitOfWork.PackagingProductRepository.All().First(p => p.Weight > 0);
                var destinations   = RVCUnitOfWork.LocationRepository.Filter(l => l.LocationType == LocationType.Warehouse).Take(2).ToList();
                var treatment      = RVCUnitOfWork.InventoryTreatmentRepository.All().First();

                const int quantity0  = 100;
                const int quantity1  = 101;
                var       now        = DateTime.Now;
                var       parameters = new CreateProductionBatchResultsParameters
                {
                    UserToken                = TestUser.UserName,
                    ProductionBatchKey       = new LotKey(unfinishedBatch),
                    ProductionLineKey        = new LocationKey(productionLine),
                    ProductionShiftKey       = "SHIFTTEST",
                    ProductionStartTimestamp = new DateTime(2014, 1, 1, now.Hour, now.Minute, now.Second, now.Millisecond),
                    ProductionEndTimestamp   = new DateTime(2014, 1, 2, now.Hour, now.Minute, now.Second, now.Millisecond),
                    InventoryItems           = new[]
                    {
                        new BatchResultItemParameters
                        {
                            PackagingProduct   = packaging,
                            Location           = destinations[0],
                            InventoryTreatment = treatment,
                            Quantity           = quantity0
                        },
                        new BatchResultItemParameters
                        {
                            PackagingProduct   = packaging,
                            Location           = destinations[1],
                            InventoryTreatment = treatment,
                            Quantity           = quantity1
                        }
                    }
                };

                if (destinations[0] == null || destinations[0] == destinations[1])
                {
                    Assert.Inconclusive("The InventoryItems must specify different WarehouseLocations in order to be valid for this test.");
                }

                //Act
                var result    = Service.CreateProductionBatchResults(parameters);
                var lotString = GetKeyFromConsoleString(ConsoleOutput.SyncProductionResults);

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

                var newLot = int.Parse(lotString);

                using (var context = new RioAccessSQLEntities())
                {
                    var lot = context.tblLots.First(o => o.Lot == newLot);
                    Assert.AreEqual(0, lot.LotStat);
                }
            }