/// <summary> /// Creates a mock for the interface labordashboar helper /// </summary> /// <param name="notes">the dashboard notes to create</param> /// <param name="rwType">the rwtype to return for all methods calculating the cumulated rw type</param> /// <param name="dashboardInfos">the dashboard infos created by all methods ToDashbardInfo...</param> /// <param name="productionOrderItem">production order item for toProductionOtderItem</param> /// <param name="productionOrderItems">collection of production order items for toProductionOrderItems</param> /// <returns>A mock for the labor dashboard helper</returns> public static ILaborDashboardHelper GetLaborDashboardHelper(List <DashboardNote> notes = null, RwType rwType = RwType.Ok, List <DashboardInfo> dashboardInfos = null, ProductionOrderItem productionOrderItem = null, ICollection <ProductionOrderItem> productionOrderItems = null) { var mock = new Mock <ILaborDashboardHelper> { Name = "MockHelperLaborDashboardHelper.GetLaborDashboardHelper", DefaultValue = DefaultValue.Mock }; mock.Setup(x => x.CalcRwType(It.IsAny <RwType>(), It.IsAny <RwType>())) .Returns(rwType); mock.Setup(x => x.ToRwTypeAll(It.IsAny <IEnumerable <TestValue> >())) .Returns(rwType) ; mock.Setup(x => x.ToDashboardInfos(It.IsAny <IEnumerable <TestValue> >())) .Returns(dashboardInfos); mock.Setup(x => x.ToDashboardNote(It.IsAny <IEnumerable <TestValue> >())) .Returns(notes); mock.Setup(x => x.ToDashboardInfosBabyDiapers(It.IsAny <TestValue>())) .Returns(dashboardInfos); mock.Setup(x => x.ToDashboardInfosIncontinencePad(It.IsAny <TestValue>())) .Returns(dashboardInfos); mock.Setup(x => x.ToProductionOrderItem(It.IsAny <TestSheet>())) .Returns(productionOrderItem); mock.Setup(x => x.ToProductionOrderItems(It.IsAny <ICollection <TestSheet> >())) .Returns(productionOrderItems); return(mock.Object); }
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); }