public void InitTestSheetForFaNrTestNotFoundShift() { var now = DateTime.Now; var shift = new ShiftSchedule { Name = "The One", ShiftType = ShiftType.Late, EndTime = new TimeSpan(now.Hour - 2, now.Minute, now.Second), StartTime = new TimeSpan(now.Hour + 2, now.Minute, now.Second), StartDay = now.DayOfWeek, EndDay = now.AddDays(1) .DayOfWeek }; var productionOrderListQuery = new List <ProductionOrder> { new ProductionOrder { FaNr = "666" } }; var shiftSheduleListQuery = new List <ShiftSchedule> { shift }; var shiftSheduleRepository = MockHelperBll.GetAllShiftSchedules(shiftSheduleListQuery.AsQueryable()); var productionOrderRepository = MockHelperBll.GetAllProductionOrders(productionOrderListQuery.AsQueryable()); var shifthelper = MockHelperBll.GetShiftHelper(null); var target = new LaborCreatorBll(new NLogLoggerFactory()) { ProductionOrderRepository = productionOrderRepository, ShiftHelper = shifthelper, TestSheetRepository = null }; var actual = target.InitTestSheetForFaNr("666"); actual.Should() .BeNull("because no shift existing"); }
public void InitTestSheetForFaNrTestPassing() { var now = DateTime.Now; var testsheet = new TestSheet { FaNr = "666", ShiftType = ShiftType.Late, DayInYear = now.DayOfYear }; var shift = new ShiftSchedule { Name = "The One", ShiftType = ShiftType.Late, EndTime = new TimeSpan(now.Hour + 2, now.Minute, now.Second), StartTime = new TimeSpan(now.Hour - 2, now.Minute, now.Second), StartDay = now.DayOfWeek, EndDay = now.AddDays(1) .DayOfWeek }; var productionorder = new ProductionOrder { FaNr = "666", Article = new Article(), Machine = new Machine { MachineNr = "M12" }, Component = new ProductionOrderComponent(), EndDateTime = now, StartDateTime = now, FaId = 1, ArticleId = 1, MachineId = 1 }; var productionOrderListQuery = new List <ProductionOrder> { productionorder }; var shiftSheduleListQuery = new List <ShiftSchedule> { shift }; var testSheetList = new List <TestSheet> { testsheet }; var shiftSheduleRepository = MockHelperBll.GetAllShiftSchedules(shiftSheduleListQuery.AsQueryable()); var productionOrderRepository = MockHelperBll.GetAllProductionOrders(productionOrderListQuery.AsQueryable()); var testSheetRepository = MockHelperBll.TestSheetRepository(testSheetList.AsQueryable()); var shifthelper = MockHelperBll.GetShiftHelper(ShiftType.Late); var target = new LaborCreatorBll(new NLogLoggerFactory()) { ProductionOrderRepository = productionOrderRepository, ShiftHelper = shifthelper, TestSheetRepository = testSheetRepository }; var actual = target.InitTestSheetForFaNr("666"); actual.Should() .NotBeNull("should be initialized"); actual.FaNr.Should() .Be(productionorder.FaNr); actual.ShiftType.Should() .Be(shift.ShiftType); actual.ArticleType.Should() .Be(productionorder.Article.ArticleType); actual.CreatedDateTime.Hour.Should() .Be(now.Hour); actual.CreatedDateTime.Minute.Should() .BeLessOrEqualTo(now.Minute); actual.DayInYear.Should() .Be(now.DayOfYear); actual.MachineNr.Should() .Be(productionorder.Machine.MachineNr); actual.TestValues.Count.Should() .Be(6); actual.TestValues.Should() .Contain(value => value.TestValueType == TestValueType.Average); actual.TestValues.Should() .Contain(value => value.TestValueType == TestValueType.StandardDeviation); actual.SAPNr.Should() .Be(productionorder.Component.ComponentNr); actual.SizeName.Should() .Be(productionorder.Article.SizeName); actual.ProductName.Should() .Be(productionorder.Article.ProductName); actual.SAPType.Should() .Be(productionorder.Component.ComponentType); }