/// <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);
        }
Пример #2
0
        public void FindValidatorTypeFromReferences()
        {
            var targetType           = typeof(User);
            var validatorGenericType = typeof(IValidator <>).MakeGenericType(new[] { targetType });

            validatorGenericType.IsGenericType.Should().Be.True();

#if !SILVERLIGHT
            var validatorConcreteType =
                AppDomain.CurrentDomain
                .GetAssemblies()
                .SelectMany(asm => asm.GetTypes())
                .FirstOrDefault(type => TypeTool.IsSameOrSubclassOrImplementedOf(type, validatorGenericType));
#else
            var validatorConcreteType =
                Assembly
                .GetExecutingAssembly()
                .GetTypes()
                .Where(type => RwType.IsSameOrSubclassOrImplementedOf(type, validatorGenericType))
                .FirstOrDefault();
#endif

            validatorConcreteType.Should().Not.Be.Null();

            validatorConcreteType.Should().Be(typeof(UserValidator));
        }
Пример #3
0
 /// <summary>
 ///     Calculates the rwtype to get the more important of the before or actual
 /// </summary>
 /// <param name="before">the rwtype before</param>
 /// <param name="rwType">the rwtype at the moment</param>
 /// <returns>the rwtype that is more important</returns>
 public RwType CalcRwType(RwType before, RwType?rwType)
 {
     if (rwType == null)
     {
         return(before);
     }
     if ((before == RwType.Worse) || (rwType == RwType.Worse))
     {
         return(RwType.Worse);
     }
     return(before == RwType.SomethingWorse ? RwType.SomethingWorse : rwType.Value);
 }
Пример #4
0
 /// <summary>
 ///     Generates a Dashboard Info with the given param values
 /// </summary>
 /// <param name="key">the key for the info as a explaining text</param>
 /// <param name="value">the value for the info</param>
 /// <param name="rw">the rw type for the info</param>
 /// <returns></returns>
 private DashboardInfo ToDashboardInfo(String key, String value, RwType rw) => new DashboardInfo
 {
     InfoValue = value, InfoKey = key, RwType = rw
 };