public void ValidateSection2_WithMultileSubValidators_ShouldRunSection2() { //Arrange var doubleLeft = new TestSimpleValidator <SomeModel>(); doubleLeft.ValidateFunc = x => { doubleLeft.Start(new ValidationInfoBase(_guid)); doubleLeft.Pass(); }; var doubleRight = new TestSimpleValidator <SomeModel>(); doubleRight.ValidateFunc = x => { doubleRight.Start(new ValidationInfoBase(_guid2)); doubleRight.Fail(); }; _sut = new TestSectionedValidator <SomeModel>(); _sut.Init(() => { _sut.Section(Section, m => _sut.RunValidator(doubleLeft, m.Some)); _sut.Section(Section2, m => _sut.RunValidator(doubleRight, m.Some)); }); //Act var result = _sut.ValidateSection(Section2, _model); //Assert Assert.IsFalse(result.Passes.Any()); Assert.IsTrue(result.Fails.Count() == 1); Assert.IsTrue(result.Fails.First().Guid == _guid2); }
public void ValidateSection_ThatDoesntExist_ShouldThrow() { //Arrange _sut = new TestSectionedValidator <SomeModel>(); //Act TestDelegate test = () => _sut.ValidateSection(Section, _model); //Assert Assert.Throws <ValidatorSectionNotFoundException>(test); }
public void ValidateSection_WithAsyncSection_ShouldReturnSomething() { //Arrange _sut = new TestSectionedValidator <SomeModel>(); _sut.Init(() => _sut.AsyncSection(Section, async m => {})); //Act var result = _sut.ValidateSection(Section, _model); //Assert Assert.NotNull(result); }
public void ValidateSection2_ShouldTestOnlySection2() { //Arrange _sut = new TestSectionedValidator <SomeModel>(); _sut.Init(() => { _sut.Section(Section, x => { _sut.Start(new ValidationInfoBase(_guid)); _sut.Pass(); }); _sut.Section(Section2, x => { _sut.Start(new ValidationInfoBase(_guid2)); _sut.Fail(); }); }); //Act var result = _sut.ValidateSection(Section2, _model); //Assert Assert.IsFalse(result.Passes.Any()); Assert.IsTrue(result.Fails.Count() == 1); Assert.IsTrue(result.Fails.First().Guid == _guid2); }