public void SetUp() { this.validations = A.Fake <ArgumentValidations <int> >(); A.CallTo(() => this.validations.IsValid(A <int> .Ignored)).Returns(true); this.Validator = new TestableValidator(this.validations); }
public static ArgumentValidator <FakeObject> IsThis(this ArgumentValidations <FakeObject> validations, object fakedObject) { return(ArgumentValidator <FakeObject> .Create(validations, x => x.Equals(Fake.GetFakeObject(fakedObject)), "Specified FakeObject")); }
public static ArgumentValidator <Expression> ProducesValue(this ArgumentValidations <Expression> validations, object expectedValue) { return(ArgumentValidator <Expression> .Create(validations, x => object.Equals(expectedValue, ExpressionManager.GetValueProducedByExpression(x)), "Expression that produces the value {0}".FormatInvariant(expectedValue))); }
public static ArgumentValidator <T> IsThisSequence <T>(this ArgumentValidations <T> validations, params object[] collection) where T : IEnumerable { return(ArgumentValidator <T> .Create(validations, x => x.Cast <object>().SequenceEqual(collection.Cast <object>()), "Same sequence")); }
public void SetUp() { this.parentValidations = A.Fake <ArgumentValidations <string> >(); A.CallTo(() => this.parentValidations.IsValid(A <string> .Ignored)).Returns(true); }
public static ArgumentValidator <string> IsLongerThan(this ArgumentValidations <string> validations, int length) { return(ArgumentValidator <string> .Create(x => x.Length > length, string.Format(CultureInfo.InvariantCulture, "Longer than {0}", length))); }
public static ArgumentValidator <string> StartsWith(this ArgumentValidations <string> validations, string beginning) { return(ArgumentValidator <string> .Create(validations, x => x.StartsWith(beginning), string.Format("Starts with \"{0}\"", beginning))); }
/// <summary> /// Validates that the specified argument is not null. /// </summary> /// <typeparam name="T">The type of the argument.</typeparam> /// <param name="validations">The validations to extend.</param> /// <returns>A validator.</returns> public static ArgumentValidator <T> IsNotNull <T>(this ArgumentValidations <T> validations) where T : class { return(ArgumentValidator <T> .Create(x => x != null, "Not NULL")); }
public TestableValidator(ArgumentValidations <int> validations) : base(validations) { }