public void AddShiftsOnDifferentDaysWithSameTeam() { Production production = new Production("Machine A", new ProductNumber("11232"), new OrderNumber("1234"), 1000, 124); ProductionTeam team = new ProductionTeam("Team 1"); DateTime start1 = new DateTime(2008, 10, 12, 8, 30, 0); DateTime start2 = new DateTime(2008, 11, 12, 8, 30, 0); ProductionShift shift1 = production.AddProductionShift(team, start1); ProductionShift shift2 = production.AddProductionShift(team, start2); CollectionAssert.AreEquivalent(new [] { shift1, shift2 }, new List<ProductionShift>(production.Shifts)); }
public void AddShift() { Production production = new Production("Machine A", new ProductNumber("11232"), new OrderNumber("1234"), 1000, 124); ProductionTeam team = new ProductionTeam("Team 1"); DateTime start = new DateTime(2008, 10, 12, 8, 30, 0); ProductionShift shift = production.AddProductionShift(team, start); CollectionAssert.AreEquivalent(new [] { shift }, new List<ProductionShift>(production.Shifts)); }
public void CreateProductionLeg() { Production production = new Production("Machine A", new ProductNumber("11232"), new OrderNumber("1234"), 1000, 124); ProductionTeam team = new ProductionTeam("Team"); DateTime start = new DateTime(2008, 10, 12, 8, 30, 0); ProductionShift shift = production.AddProductionShift(team, start.Date); long counterStart = 9956; ProductionLeg leg = shift.AddProductionLeg(start, counterStart); Assert.AreEqual<DateTime>(start, leg.ProductionStart); Assert.AreEqual<long>(counterStart, leg.CounterStart); }
public void AddStopsToProductionLeg() { Production production = new Production("Machine A", new ProductNumber("11232"), new OrderNumber("1234"), 1000, 124); ProductionShift shift = production.AddProductionShift(new ProductionTeam("T"), DateTime.Now.Date); ProductionLeg leg = shift.AddProductionLeg(DateTime.Now, 0); CollectionAssert.AreEquivalent(new ProductionStopRegistration[] { }, new List<ProductionStopRegistration>(leg.ProductionStopRegistrations)); leg.AddProductionStopRegistration(new ProductionStopRegistration(stop1, new TimeSpan(0, 10, 0))); CollectionAssert.AreEquivalent(new [] { new ProductionStopRegistration(stop1, new TimeSpan(0, 10, 0)) }, new List<ProductionStopRegistration>(leg.ProductionStopRegistrations)); leg.AddProductionStopRegistration(new ProductionStopRegistration(stop3, new TimeSpan(0, 35, 0))); CollectionAssert.AreEquivalent(new [] { new ProductionStopRegistration(stop1, new TimeSpan(0, 10, 0)), new ProductionStopRegistration(stop3, new TimeSpan(0, 35, 0)) }, new List<ProductionStopRegistration>(leg.ProductionStopRegistrations)); leg.AddProductionStopRegistration(new ProductionStopRegistration(stop1, new TimeSpan(0, 12, 0))); CollectionAssert.AreEquivalent(new [] { new ProductionStopRegistration(stop1, new TimeSpan(0, 10, 0)), new ProductionStopRegistration(stop1, new TimeSpan(0, 12, 0)), new ProductionStopRegistration(stop3, new TimeSpan(0, 35, 0)) }, new List<ProductionStopRegistration>(leg.ProductionStopRegistrations)); }
public void UpdateProductionShifts() { Production production = new Production("Machine A", product1, order1, 1000, 100); using (IEntityRepository<Production> repository = factory.CreateEntityRepository<Production>()) { repository.Save(production); } ProductionShift shift1 = production.AddProductionShift(team1, new DateTime(2008, 11, 12)); ProductionShift shift2 = production.AddProductionShift(team2, new DateTime(2008, 11, 12)); using (IEntityRepository<ProductionShift> repository = factory.CreateEntityRepository<ProductionShift>()) { repository.Save(shift1); repository.Save(shift2); } using (IEntityRepository<Production> repository = factory.CreateEntityRepository<Production>()) { repository.Save(production); } using (IEntityRepository<Production> repository = factory.CreateEntityRepository<Production>()) { Production loadedProduction = repository.Load(production.Id); Assert.AreNotSame(production, loadedProduction); Assert.AreEqual(production, loadedProduction); Assert.AreEqual(production.Machine, loadedProduction.Machine); Assert.AreEqual(production.Product, loadedProduction.Product); Assert.AreEqual(production.Order, loadedProduction.Order); Assert.AreEqual(production.ExpectedItems, loadedProduction.ExpectedItems); Assert.AreEqual(production.ProducedItemsPerHour, loadedProduction.ProducedItemsPerHour); CollectionAssert.AreEquivalent(new List<ProductionShift>(production.Shifts), new List<ProductionShift>(loadedProduction.Shifts)); } }
public void AddShiftsOnSameDayWithSameTeam() { Production production = new Production("Machine A", new ProductNumber("11232"), new OrderNumber("1234"), 1000, 124); ProductionTeam team = new ProductionTeam("Team 1"); DateTime start = new DateTime(2008, 10, 12, 8, 30, 0); ProductionShift shift1 = production.AddProductionShift(team, start); ProductionShift shift2 = production.AddProductionShift(team, start.AddHours(1)); }
private Production Duplicate(Production p, IEnumerable<ProductionShift> shifts) { Production production = new Production(p.Machine, p.Product, p.Order, p.ExpectedItems, p.ProducedItemsPerHour, p.ValidatedStartTime); foreach (var shift in shifts) { var s = production.AddProductionShift(shift.Team, shift.ProductionStart.Date); foreach (var leg in shift.ProductionLegs) { var l = s.AddProductionLeg(leg.ProductionStart, leg.CounterStart); foreach (var registration in shift.ProductionStopRegistrations) { l.AddProductionStopRegistration(registration); } l.UpdateStatistics(leg.ProductionEnd, leg.CounterEnd, leg.DiscardedItems); } } return production; }
public void CreateWithNegativeCounterStart() { DateTime time = DateTime.Now; Production production = new Production("Machine A", new ProductNumber("11232"), new OrderNumber("1234"), 1000, 124); ProductionShift shift = production.AddProductionShift(new ProductionTeam("T"), DateTime.Now.Date); ProductionLeg leg = shift.AddProductionLeg(DateTime.Now, -1); }
public void UpdateWithProductionStartSameAsProductionEnd() { DateTime time = DateTime.Now; Production production = new Production("Machine A", new ProductNumber("11232"), new OrderNumber("1234"), 1000, 124); ProductionShift shift = production.AddProductionShift(new ProductionTeam("T"), DateTime.Now.Date); ProductionLeg leg = shift.AddProductionLeg(time, 0); leg.UpdateStatistics(time, 0, 0); }
public void UpdateWithNegativeDiscarded() { DateTime time = DateTime.Now; Production production = new Production("Machine A", new ProductNumber("11232"), new OrderNumber("1234"), 1000, 124); ProductionShift shift = production.AddProductionShift(new ProductionTeam("T"), DateTime.Now.Date); ProductionLeg leg = shift.AddProductionLeg(time, 0); leg.UpdateStatistics(time.AddMinutes(10), 50, -5); }
public void UpdateWithCounterEndSmallerThanCounterStart() { DateTime time = DateTime.Now; Production production = new Production("Machine A", new ProductNumber("11232"), new OrderNumber("1234"), 1000, 124); ProductionShift shift = production.AddProductionShift(new ProductionTeam("T"), DateTime.Now.Date); ProductionLeg leg = shift.AddProductionLeg(time, 400); leg.UpdateStatistics(time.AddMinutes(10), 300, 0); }
public void ProductionStatistics() { DateTime start = new DateTime(2008, 10, 12, 8, 30, 0); DateTime end = new DateTime(2008, 10, 12, 14, 45, 0); long counterStart = 1111; long counterEnd = 12342; long discardedItems = 534; Production production = new Production("Machine A", new ProductNumber("11232"), new OrderNumber("1234"), 1000, 124); ProductionShift shift = production.AddProductionShift(new ProductionTeam("T"), DateTime.Now.Date); ProductionLeg leg = shift.AddProductionLeg(start, counterStart); leg.UpdateStatistics(end, counterEnd, discardedItems); Assert.AreEqual<long>(11231, leg.ProducedItems); Assert.AreEqual<long>(10697, leg.ProducedApprovedItems); Assert.AreEqual<TimeSpan>(new TimeSpan(6, 15, 0), leg.ProductionTime); }