protected override string PropertyValidation(System.Reflection.PropertyInfo pi)
        {
            if (pi.Is(() => IsEmpty) && IsEmpty)
                return "IsEmpty is true";

            return base.PropertyValidation(pi);
        }
Example #2
0
        public void WhenAllEnumerable()
        {
            var xs = new[] {
                    Observable.Return(100),
                    Observable.Timer(TimeSpan.FromSeconds(1)).Select(_ => 5),
                    Observable.Range(1, 4)
            }.Select(x => x).WhenAll().Wait();

            xs.Is(100, 5, 4);
        }
Example #3
0
        public void WhenAllUnitEnumerable()
        {
            var xs = new[] {
                    Observable.Return(100).AsUnitObservable(),
                    Observable.Timer(TimeSpan.FromSeconds(1)).AsUnitObservable(),
                    Observable.Range(1, 4).AsUnitObservable()
            }.Select(x => x).WhenAll().Wait();

            xs.Is(Unit.Default);
        }
        protected override string PropertyValidation(System.Reflection.PropertyInfo pi)
        {
            if (pi.Is(() => Messages))
            {
                if (Messages == null || !Messages.Any())
                    return EmailTemplateMessage.ThereAreNoMessagesForTheTemplate.NiceToString();

                if (Messages.GroupCount(m => m.CultureInfo).Any(c => c.Value > 1))
                    return EmailTemplateMessage.TheresMoreThanOneMessageForTheSameLanguage.NiceToString();
            }

            return base.PropertyValidation(pi);
        }
        protected override string ChildPropertyValidation(ModifiableEntity sender, System.Reflection.PropertyInfo pi)
        {
            var column = sender as ChartScriptColumnEntity;
            if (column != null && pi.Is(() => column.IsGroupKey))
            {
                if (column.IsGroupKey)
                {
                    if (!ChartUtils.Flag(ChartColumnType.Groupable, column.ColumnType))
                        return "{0} can not be true for {1}".FormatWith(pi.NiceName(), column.ColumnType.NiceToString());
                }
            }

            var param = sender as ChartScriptParameterEntity;
            if (param != null && pi.Is(() => param.ColumnIndex))
            {
                if (param.ColumnIndex == null && param.ShouldHaveColumnIndex())
                    return ValidationMessage._0IsNecessary.NiceToString(pi.NiceName());

                if (param.ColumnIndex.HasValue && !(0 <= param.ColumnIndex && param.ColumnIndex < this.Columns.Count))
                    return ValidationMessage._0HasToBeBetween1And2.NiceToString(pi.NiceName(), 0, this.columns.Count);
            }

            return base.ChildPropertyValidation(sender, pi);
        }
        protected override string PropertyValidation(System.Reflection.PropertyInfo pi)
        {
            if (pi.Is(() => GroupBy))
            {
                if (GroupBy == GroupByChart.Always || GroupBy == GroupByChart.Optional)
                {
                    if (!Columns.Any(a => a.IsGroupKey))
                        return "{0} {1} requires some key columns".FormatWith(pi.NiceName(), groupBy.NiceToString());
                }
                else
                {
                    if (Columns.Any(a => a.IsGroupKey))
                        return "{0} {1} should not have key".FormatWith(pi.NiceName(), groupBy.NiceToString());
                }
            }

            if (pi.Is(() => Script))
            {
                if (!Regex.IsMatch(Script, @"function\s+DrawChart\s*\(\s*chart\s*,\s*data\s*\)", RegexOptions.Singleline))
                {
                    return "{0} should be a definition of function DrawChart(chart, data)".FormatWith(pi.NiceName());
                }
            }

            return base.PropertyValidation(pi);
        }
Example #7
0
 public void WhenAllUnitEnumerable()
 {
     SetScehdulerForImport();
     var xs = new[] {
             Observable.Return(100).AsUnitObservable(),
             Observable.Timer(TimeSpan.FromSeconds(1)).AsUnitObservable(),
             Observable.Range(1, 4).AsUnitObservable()
     }.Select(x => x).WhenAll().Wait();
     xs.Is(Unit.Default);
     UniRx.Scheduler.SetDefaultForUnity();
 }
        protected override string PropertyValidation(System.Reflection.PropertyInfo pi)
        {
            if (pi.Is(() => StartDate) || pi.Is(() => EndDate))
            {
                if (EndDate != null && StartDate >= EndDate)
                    return SMSTemplateMessage.EndDateMustBeHigherThanStartDate.NiceToString();
            }

            if (pi.Is(() => Messages))
            {
                if (Messages == null || !Messages.Any())
                    return SMSTemplateMessage.ThereAreNoMessagesForTheTemplate.NiceToString();

                if (Messages.GroupCount(m => m.CultureInfo).Any(c => c.Value > 1))
                    return SMSTemplateMessage.TheresMoreThanOneMessageForTheSameLanguage.NiceToString();
            }

            return base.PropertyValidation(pi);
        }