public void ValidationWheelsExampleTest() { var sut = new CarValidator(); Poly.Create.From("Valid Car", () => MakeValidCar()) .Consider("No wheels !", c => c.Wheels.Clear()) .Consider("1 more wheel !", c => c.Wheels.Add(new Wheel(c,5))) .Test( act: o => sut.Validate(o), assert: actual => AssertIsInvalid(actual)) .AssertAllPassed(); }
public void ValidationExampleTest() { var sut = new CarValidator(); Poly.Create.From("A car with all the proper attributes", () => MakeValidCar()) .With(c => c.NumberOfDoors, 0) .With(c => c.NumberOfDoors, -1) .WithNull(c => c.BrandName) .WithNullOrWhitespace(c => c.ModelName) .WithFalse(c => c.NeedsEngine, fromThere => fromThere.IgnoreSelf("ignore case with only 'NeedsEngine = false'") .With(c => c.Engine, new Engine()) ) .WithTrue(c => c.NeedsEngine, fromHere => fromHere.IgnoreSelf("ignore case with only 'NeedsEngine = true'") .WithNull(c => c.Engine) ) .Test( act: o => sut.Validate(o), assert: actual => AssertIsInvalid(actual)) .AssertAllPassed(); }
public void ValidCase() { var sut = new CarValidator(); Assert.True(sut.Validate(MakeValidCar()), "valid case should be valid (duh)"); }