Skip to content

Commit

Permalink
add some checker unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
fs7744 committed Apr 10, 2016
1 parent c3075d1 commit 2d714e8
Show file tree
Hide file tree
Showing 3 changed files with 1,080 additions and 0 deletions.
36 changes: 36 additions & 0 deletions ObjectValidator/Syntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,18 @@ public static partial class Syntax

#region NextRuleChecker

public static IRuleMessageBuilder<T, TProperty> In<T, TProperty>(this IRuleMessageBuilder<T, TProperty> builder, IEnumerable<TProperty> value)
{
var ruleBuilder = builder as IRuleBuilder<T, TProperty>;
return ruleBuilder.ThenRuleFor(ruleBuilder.ValueExpression).In(value);
}

public static IRuleMessageBuilder<T, TProperty> CustomCheck<T, TProperty>(this IRuleMessageBuilder<T, TProperty> builder, Func<TProperty, IEnumerable<ValidateFailure>> func)
{
var ruleBuilder = builder as IRuleBuilder<T, TProperty>;
return ruleBuilder.ThenRuleFor(ruleBuilder.ValueExpression).CustomCheck(func);
}

public static IRuleMessageBuilder<T, TProperty> Must<T, TProperty>(this IRuleMessageBuilder<T, TProperty> builder, Func<TProperty, bool> func)
{
var ruleBuilder = builder as IRuleBuilder<T, TProperty>;
Expand Down Expand Up @@ -417,6 +429,12 @@ public static partial class Syntax
return ruleBuilder.ThenRuleFor(ruleBuilder.ValueExpression).GreaterThan(value);
}

public static IRuleMessageBuilder<T, DateTime> GreaterThan<T>(this IRuleMessageBuilder<T, DateTime> builder, DateTime value)
{
var ruleBuilder = builder as IRuleBuilder<T, DateTime>;
return ruleBuilder.ThenRuleFor(ruleBuilder.ValueExpression).GreaterThan(value);
}

public static IRuleMessageBuilder<T, double> GreaterThan<T>(this IRuleMessageBuilder<T, double> builder, double value)
{
var ruleBuilder = builder as IRuleBuilder<T, double>;
Expand All @@ -435,6 +453,12 @@ public static partial class Syntax
return ruleBuilder.ThenRuleFor(ruleBuilder.ValueExpression).GreaterThan(value);
}

public static IRuleMessageBuilder<T, DateTime> GreaterThanOrEqual<T>(this IRuleMessageBuilder<T, DateTime> builder, DateTime value)
{
var ruleBuilder = builder as IRuleBuilder<T, DateTime>;
return ruleBuilder.ThenRuleFor(ruleBuilder.ValueExpression).GreaterThanOrEqual(value);
}

public static IRuleMessageBuilder<T, float> GreaterThanOrEqual<T>(this IRuleMessageBuilder<T, float> builder, float value)
{
var ruleBuilder = builder as IRuleBuilder<T, float>;
Expand Down Expand Up @@ -465,6 +489,12 @@ public static partial class Syntax
return ruleBuilder.ThenRuleFor(ruleBuilder.ValueExpression).GreaterThanOrEqual(value);
}

public static IRuleMessageBuilder<T, DateTime> LessThan<T>(this IRuleMessageBuilder<T, DateTime> builder, DateTime value)
{
var ruleBuilder = builder as IRuleBuilder<T, DateTime>;
return ruleBuilder.ThenRuleFor(ruleBuilder.ValueExpression).LessThan(value);
}

public static IRuleMessageBuilder<T, float> LessThan<T>(this IRuleMessageBuilder<T, float> builder, float value)
{
var ruleBuilder = builder as IRuleBuilder<T, float>;
Expand Down Expand Up @@ -495,6 +525,12 @@ public static partial class Syntax
return ruleBuilder.ThenRuleFor(ruleBuilder.ValueExpression).LessThan(value);
}

public static IRuleMessageBuilder<T, DateTime> LessThanOrEqual<T>(this IRuleMessageBuilder<T, DateTime> builder, DateTime value)
{
var ruleBuilder = builder as IRuleBuilder<T, DateTime>;
return ruleBuilder.ThenRuleFor(ruleBuilder.ValueExpression).LessThanOrEqual(value);
}

public static IRuleMessageBuilder<T, float> LessThanOrEqual<T>(this IRuleMessageBuilder<T, float> builder, float value)
{
var ruleBuilder = builder as IRuleBuilder<T, float>;
Expand Down
Loading

0 comments on commit 2d714e8

Please sign in to comment.