public void TestValueThatIsNotAString() { IValueExtractor ive = MockRepository.GenerateStub<IValueExtractor>(); ive.Expect(o => o.ExtractValue(null)).Return(new Object()); ive.Expect(o => o.SourceName).Return("property"); var rv = new RangeLengthValidator(ive, 1, 10); Assert.Throws(typeof (ArgumentException), () => rv.Validate(null)); }
public void TestNullString() { IValueExtractor ive = MockRepository.GenerateStub<IValueExtractor>(); ive.Expect(o => o.ExtractValue(null)).Return(null); ive.Expect(o => o.SourceName).Return("property"); var rv = new RangeLengthValidator(ive, 1, 10); Assert.IsFalse(rv.Validate(null)); }
public void TestRangeLenght() { var newObject = new object(); IValueExtractor ive = MockRepository.GenerateStub<IValueExtractor>(); ive.Expect(o => o.ExtractValue(null)).IgnoreArguments().Return("Valid"); ive.Expect(o => o.SourceName).Return("property"); var rv = new RangeLengthValidator(ive, 100); Assert.IsTrue(rv.Validate(newObject), "Range incorrect validation"); }
public void TestValidString() { IValueExtractor ive = MockRepository.GenerateStub<IValueExtractor>(); ive.Expect(o => o.ExtractValue(null)).Return("String OK"); ive.Expect(o => o.SourceName).Return("property"); var rv = new RangeLengthValidator(ive, 1, 10); SingleValidationResult res = rv.Validate(null); Assert.IsTrue(res); }
public void TestInvalidStringTooLength() { IValueExtractor ive = MockRepository.GenerateStub<IValueExtractor>(); ive.Expect(o => o.ExtractValue(null)).Return("This string exceeds 10 charachters"); ive.Expect(o => o.SourceName).Return("property"); var rv = new RangeLengthValidator(ive, 1, 10); SingleValidationResult res = rv.Validate(null); Assert.IsFalse(res); Assert.That(res.ExpectedValue, Text.Contains("[1,10]")); }