public void Passing_Good_Configuration_Will_Not_Throw_Any_Exceptions_On_Assert() { // arrange var expression = new ValidatorConfigurationExpression(); expression.AddProfile <Profile2>(); expression.AddProfile <Profile1>(); _subject = new AutoValidation(expression); // act Action action = () => _subject.AssertExpressionsAreValid(); // assert action.Should().NotThrow(); }
public void Init() { var expression = new ValidatorConfigurationExpression(); expression.AddProfile <Profile1>(); _subject = new ValidatorFactory(expression); }
public void Passing_Bad_Configuration_Will_Throw() { // arrange var expression = new ValidatorConfigurationExpression(); expression.AddProfile <DuplicateInvalidMappingProfile>(); expression.AddProfile <MissingMappingProfile>(); _subject = new AutoValidation(expression); try { _subject.AssertExpressionsAreValid(); } catch (ConfigurationExpressionException ex) { ex.Errors.ToList().Count.Should().Be(2); ex.Errors.Should().Contain(e => e.ProfileType == typeof(DuplicateInvalidMappingProfile)); ex.Errors.Should().Contain(e => e.ProfileType == typeof(MissingMappingProfile)); } }
public void Add_Profile_By_Instance_Is_Stored() { // arrange var p1 = new Profile1(); _subject.Profiles.Should().BeEmpty(); // act _subject.AddProfile(p1); // assert _subject.Profiles.Should().Contain(x => x.GetType() == p1.GetType()); }