コード例 #1
0
        public void GetTestSheetForActualAndLastThreeShiftsFoundTest2()
        {
            var now = DateTime.Now;

            var testsheet = new TestSheet
            {
                FaNr            = "666",
                ShiftType       = ShiftType.Late,
                DayInYear       = now.DayOfYear,
                CreatedDateTime = now
            };

            var testsheet2 = new TestSheet
            {
                FaNr            = "666",
                ShiftType       = ShiftType.Late,
                DayInYear       = now.DayOfYear,
                CreatedDateTime = now.AddDays(-7)
            };

            var shift = new ShiftSchedule
            {
                Name      = "The One",
                ShiftType = ShiftType.Late,
                EndTime   = new TimeSpan(now.Hour + 2, now.Minute + 10, now.Second),
                StartTime = new TimeSpan(now.Hour - 2, now.Minute - 10, now.Second),
                StartDay  = now.DayOfWeek,
                EndDay    = now.AddDays(1)
                            .DayOfWeek
            };

            var shiftSheduleListQuery = new List <ShiftSchedule>
            {
                shift,
                shift
            };
            var testSheetListQuery = new List <TestSheet>
            {
                testsheet,
                testsheet2
            };

            var testSheetRepository = MockHelperBll.TestSheetRepository(testSheetListQuery.AsQueryable());
            var shifthelper         = MockHelperBll.GetShiftHelper(ShiftType.Late, shift, shiftSheduleListQuery);

            var target = new LaborDashboardBll(new NLogLoggerFactory())
            {
                ShiftHelper = shifthelper,
                TestSheets  = testSheetRepository
            };

            var actual = target.GetTestSheetForActualAndLastThreeShifts();

            actual.Count.Should()
            .Be(1);
        }
コード例 #2
0
        public void GetTestSheetForFaNrTestNormal()
        {
            var now = DateTime.Now;

            var testsheet = new TestSheet
            {
                FaNr            = "666",
                ShiftType       = ShiftType.Late,
                DayInYear       = now.DayOfYear,
                CreatedDateTime = 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 shiftSheduleListQuery = new List <ShiftSchedule>
            {
                shift
            };

            var shiftSheduleRepository = MockHelperBll.GetAllShiftSchedules(shiftSheduleListQuery.AsQueryable());
            var testSheetList          = new List <TestSheet>
            {
                testsheet
            };

            var testSheetRepository = MockHelperBll.TestSheetRepository(testSheetList.AsQueryable());
            var shifthelper         = MockHelperBll.GetShiftHelper(ShiftType.Late);

            var target = new LaborCreatorBll(new NLogLoggerFactory())
            {
                ProductionOrderRepository = null,
                ShiftHelper         = shifthelper,
                TestSheetRepository = testSheetRepository
            };

            var actual = target.GetTestSheetForFaNr("666")
                         .Should()
                         .Be(testsheet);
        }
コード例 #3
0
        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");
        }
コード例 #4
0
        public void RunningTestSheetsTest2()
        {
            var now = DateTime.Now;

            var testsheet1 = new TestSheet
            {
                FaNr      = "666",
                ShiftType = ShiftType.Late,
                DayInYear = now.DayOfYear
            };

            var testsheet2 = new TestSheet
            {
                FaNr      = "7",
                ShiftType = ShiftType.Late,
                DayInYear = now.DayOfYear
            };
            var testsheet3 = new TestSheet
            {
                FaNr      = "5",
                ShiftType = ShiftType.Late,
                DayInYear = now.DayOfYear + 1
            };
            var testsheet4 = new TestSheet
            {
                FaNr      = "127",
                ShiftType = ShiftType.Morning,
                DayInYear = now.DayOfYear
            };
            var testsheet5 = new TestSheet
            {
                FaNr      = "778",
                ShiftType = ShiftType.Late,
                DayInYear = now.DayOfYear - 1
            };
            var testsheet6 = new TestSheet
            {
                FaNr      = "111",
                ShiftType = ShiftType.Night,
                DayInYear = now.DayOfYear - 1
            };
            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 testsheets = new List <TestSheet> {
                testsheet1, testsheet2
            };

            var shiftSheduleListQuery = new List <ShiftSchedule>
            {
                shift
            };

            var shiftSheduleRepository = MockHelperBll.GetAllShiftSchedules(shiftSheduleListQuery.AsQueryable());
            var testSheetList          = new List <TestSheet>
            {
                testsheet1,
                testsheet2,
                testsheet3,
                testsheet4,
                testsheet5,
                testsheet6
            };

            var testSheetRepository = MockHelperBll.TestSheetRepository(testSheetList.AsQueryable());
            var shifthelper         = MockHelperBll.GetShiftHelper(ShiftType.Late);

            var target = new LaborCreatorBll(new NLogLoggerFactory())
            {
                ProductionOrderRepository = null,
                ShiftHelper         = shifthelper,
                TestSheetRepository = testSheetRepository
            };

            var actual = target.RunningTestSheets();

            actual.Count.Should()
            .Be(2);
            actual.Should()
            .BeEquivalentTo(testsheets);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        public void GetLaborDashboardViewModelSingleTest()
        {
            var now  = DateTime.Now;
            var note = new DashboardNote
            {
                ErrorMessage = "en fehler",
                Message      = "chaibe siäch, eifach abgstellt hetter",
                Code         = "666"
            };
            var info = new DashboardInfo
            {
                RwType    = RwType.Better,
                InfoValue = "666",
                InfoKey   = "the number of the beast"
            };
            var po = new ProductionOrderItem
            {
                RwType   = RwType.Better,
                Action   = "action",
                HasNotes = true,
                Notes    = new List <DashboardNote> {
                    note
                },
                ProductionOrderName = "666",
                Controller          = "controller",
                SheetId             = 12,
                DashboardInfos      = new List <DashboardInfo> {
                    info
                }
            };

            var labordashboardbllmock =
                MockHelperBll.GetLaborDashboardBll(
                    new List <TestSheet> {
                new TestSheet {
                    MachineNr = "M10", CreatedDateTime = now
                }
            }
                    );
            var labordashboardhelpermock =
                MockHelperLaborDashboardHelper.GetLaborDashboardHelper(
                    new List <DashboardNote> {
                note
            },
                    RwType.Better,
                    new List <DashboardInfo> {
                info
            },
                    po,
                    new List <ProductionOrderItem> {
                po
            }
                    );
            var shifthelpermock =
                MockHelperBll.GetShiftHelper(
                    lastXShiftSchedules:
                    new List <ShiftSchedule>
            {
                new ShiftSchedule {
                    ShiftType = ShiftType.Morning, StartDay = now.DayOfWeek, EndDay = now.DayOfWeek, StartTime = now.TimeOfDay, EndTime = now.TimeOfDay
                },
                new ShiftSchedule(),
                new ShiftSchedule(),
                new ShiftSchedule()
            }
                    ,
                    shiftType: ShiftType.Morning
                    ,
                    shiftScheduleCurrent:
                    new ShiftSchedule {
                ShiftType = ShiftType.Morning, StartDay = now.DayOfWeek, EndDay = now.DayOfWeek, StartTime = now.TimeOfDay, EndTime = now.TimeOfDay
            }
                    ,
                    dateExistsInShift: time => now.IsSameOrEqualTo(time)
                    );
            var target = new LaborDashboardService(new NLogLoggerFactory())
            {
                LaborDashboardBll    = labordashboardbllmock,
                LaborDashboardHelper = labordashboardhelpermock,
                ShiftHelper          = shifthelpermock
            };

            var actual = target.GetLaborDashboardViewModel();

            actual.DashboardItemM10.MachineName.Should()
            .Be("M10");
            actual.DashboardItemM11.MachineName.Should()
            .Be("M11");
            actual.DashboardItemM49.MachineName.Should()
            .Be("M49");
            actual.DashboardItemM10.ShiftItemsCurrent.Count.Should()
            .Be(1);
            actual.DashboardItemM10.ShiftItemsMinus1.Count.Should()
            .Be(1);
            actual.DashboardItemM10.ShiftItemsMinus2.Count.Should()
            .Be(1);
            actual.DashboardItemM10.ShiftItemsMinus3.Count.Should()
            .Be(1);

            actual.DashboardItemM11.ShiftItemsCurrent.Count.Should()
            .Be(0);
            actual.DashboardItemM11.ShiftItemsMinus1.Count.Should()
            .Be(0);
            actual.DashboardItemM11.ShiftItemsMinus2.Count.Should()
            .Be(0);
            actual.DashboardItemM11.ShiftItemsMinus3.Count.Should()
            .Be(0);

            actual.DashboardItemM49.ShiftItemsCurrent.Count.Should()
            .Be(0);
            actual.DashboardItemM49.ShiftItemsMinus1.Count.Should()
            .Be(0);
            actual.DashboardItemM49.ShiftItemsMinus2.Count.Should()
            .Be(0);
            actual.DashboardItemM49.ShiftItemsMinus3.Count.Should()
            .Be(0);

            actual.DashboardItemM10.ShiftItemsCurrent.ToList()[0].RwType.Should()
            .Be(po.RwType);
            actual.DashboardItemM10.ShiftItemsCurrent.ToList()[0].DashboardInfos.Count.Should()
            .Be(1);
            actual.DashboardItemM10.ShiftItemsCurrent.ToList()[0].DashboardInfos.ToList()[0].Should()
            .Be(info);
            actual.DashboardItemM10.ShiftItemsCurrent.ToList()[0].SheetId.Should()
            .Be(po.SheetId);
            actual.DashboardItemM10.ShiftItemsCurrent.ToList()[0].Action.Should()
            .Be(po.Action);
            actual.DashboardItemM10.ShiftItemsCurrent.ToList()[0].Controller.Should()
            .Be(po.Controller);
            actual.DashboardItemM10.ShiftItemsCurrent.ToList()[0].HasNotes.Should()
            .Be(po.HasNotes);
            actual.DashboardItemM10.ShiftItemsCurrent.ToList()[0].ProductionOrderName.Should()
            .Be(po.ProductionOrderName);
            actual.DashboardItemM10.ShiftItemsCurrent.ToList()[0].Notes.Count.Should()
            .Be(1);
            actual.DashboardItemM10.ShiftItemsCurrent.ToList()[0].Notes.ToList()[0].Should()
            .Be(note);
        }
コード例 #7
0
        public void GetLaborDashboardViewModelEmptyTest()
        {
            var labordashboardbllmock =
                MockHelperBll.GetLaborDashboardBll(
                    new List <TestSheet> {
                new TestSheet {
                    MachineNr = "M10"
                }
            }
                    );
            var shifthelpermock =
                MockHelperBll.GetShiftHelper(
                    lastXShiftSchedules: new List <ShiftSchedule>
            {
                new ShiftSchedule(),
                new ShiftSchedule(),
                new ShiftSchedule(),
                new ShiftSchedule()
            }
                    ,
                    dateExistsInShift: time => false
                    );
            var labordashboardhelpermock =
                MockHelperLaborDashboardHelper.GetLaborDashboardHelper(
                    new List <DashboardNote>(),
                    productionOrderItems: new List <ProductionOrderItem>()
                    );

            var target = new LaborDashboardService(new NLogLoggerFactory())
            {
                LaborDashboardBll    = labordashboardbllmock,
                LaborDashboardHelper = labordashboardhelpermock,
                ShiftHelper          = shifthelpermock
            };

            var actual = target.GetLaborDashboardViewModel();

            actual.DashboardItemM10.MachineName.Should()
            .Be("M10");
            actual.DashboardItemM10.ShiftItemsCurrent.Count.Should()
            .Be(0);
            actual.DashboardItemM10.ShiftItemsMinus1.Count.Should()
            .Be(0);
            actual.DashboardItemM10.ShiftItemsMinus2.Count.Should()
            .Be(0);
            actual.DashboardItemM10.ShiftItemsMinus3.Count.Should()
            .Be(0);
            actual.DashboardItemM11.MachineName.Should()
            .Be("M11");
            actual.DashboardItemM11.ShiftItemsCurrent.Count.Should()
            .Be(0);
            actual.DashboardItemM11.ShiftItemsMinus1.Count.Should()
            .Be(0);
            actual.DashboardItemM11.ShiftItemsMinus2.Count.Should()
            .Be(0);
            actual.DashboardItemM11.ShiftItemsMinus3.Count.Should()
            .Be(0);
            actual.DashboardItemM49.MachineName.Should()
            .Be("M49");
            actual.DashboardItemM49.ShiftItemsCurrent.Count.Should()
            .Be(0);
            actual.DashboardItemM49.ShiftItemsMinus1.Count.Should()
            .Be(0);
            actual.DashboardItemM49.ShiftItemsMinus2.Count.Should()
            .Be(0);
            actual.DashboardItemM49.ShiftItemsMinus3.Count.Should()
            .Be(0);
        }