public void PropertyShouldReturnSameBuilderForExpression()
        {
            // arrange
            var validator = new ObjectValidator<IComponent>();

            // act
            var expected = validator.Property( c => c.Site );
            var actual = validator.Property( c => c.Site );

            // assert
            Assert.Same( expected, actual );
        }
        public void PropertyShouldNotAllowNullExpression()
        {
            // arrange
            var validator = new ObjectValidator<IComponent>();
            Expression<Func<IComponent, ISite>> propertyExpression = null;

            // act
            var ex = Assert.Throws<ArgumentNullException>( () => validator.Property( propertyExpression ) );

            // assert
            Assert.Equal( "propertyExpression", ex.ParamName );
        }
        public void ValidatePropertyShouldReturnExpectedResult()
        {
            // arrange
            var validator = new ObjectValidator<IComponent>();

            validator.Property( c => c.Site ).Required();

            // act
            var actual = validator.ValidateProperty( "Site", null );

            // assert
            Assert.Equal( 1, actual.Count );
            Assert.Equal( "Site", actual[0].MemberNames.Single() );
        }
        public void ValidateObjectShouldValidateSpecifiedProperties()
        {
            // arrange
            var instance = new Mock<IComponent>().Object;
            var validator = new ObjectValidator<IComponent>();
            var propertyNames = new[] { "Site" };

            validator.Property( c => c.Site ).Required();

            // act
            var actual = validator.ValidateObject( instance, propertyNames );

            // assert
            Assert.Equal( 1, actual.Count );
            Assert.Equal( "Site", actual[0].MemberNames.Single() );
        }