public void IsSatisfiedByWithNullRequestShouldThrowArgumentNullException()
 {
     // Fixture setup
     var sut = new PropertySpecification(typeof(object), "someName");
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() =>
         sut.IsSatisfiedBy(null));
     // Teardown
 }
 public void SutIsRequestSpecification()
 {
     // Fixture setup
     // Exercise system
     var sut = new PropertySpecification(typeof(object), "someName");
     // Verify outcome
     Assert.IsAssignableFrom<IRequestSpecification>(sut);
     // Teardown
 }
 public void InitializeWithPropertyTypeAndNameShouldSetCorrespondingProperties()
 {
     // Fixture setup
     var type = typeof(string);
     var name = "someName";
     // Exercise system
     var sut = new PropertySpecification(type, name);
     // Verify outcome
     Assert.Equal(type, sut.TargetType);
     Assert.Equal(name, sut.TargetName);
     // Teardown
 }
 public void IsSatisfiedByWithRequestForPropertyShouldReturnCorrectResult(
     string propertyName,
     string requestedName,
     bool expectedResult)
 {
     // Fixture setup
     var sut = new PropertySpecification(typeof(object), propertyName);
     var request = typeof(PropertyHolder<object>).GetProperty(requestedName);
     // Exercise system
     var result = sut.IsSatisfiedBy(request);
     // Verify outcome
     Assert.Equal(expectedResult, result);
     // Teardown
 }
 public void IsSatisfiedByWithRequestForReadOnlyPropertyWithSameNameShouldReturnTrue()
 {
     // Fixture setup
     var propertyName = "Property";
     var requestedName = "Property";
     var sut = new PropertySpecification(typeof(object), propertyName);
     var request = typeof(ReadOnlyPropertyHolder<object>).GetProperty(requestedName);
     // Exercise system
     var result = sut.IsSatisfiedBy(request);
     // Verify outcome
     Assert.True(result);
     // Teardown
 }
        public void IsSatisfiedByReturnsCorrectResultAccordingToTarget(
            bool expected)
        {
            var prop = typeof(string).GetProperty("Length");
            var target = new DelegatingCriterion<PropertyInfo>
            {
                OnEquals = p =>
                {
                    Assert.Equal(prop, p);
                    return expected;
                }
            };
            var sut = new PropertySpecification(target);

            var actual = sut.IsSatisfiedBy(prop);

            Assert.Equal(expected, actual);
        }
 public void IsSatisfiedByWithInvalidRequestShouldReturnFalse(object request)
 {
     // Fixture setup
     var sut = new PropertySpecification(typeof(object), "someName");
     // Exercise system
     var result = sut.IsSatisfiedBy(request);
     // Verify outcome
     Assert.False(result);
     // Teardown
 }
 public void IsSatisfiedByWithRequestForMemberOtherThanPropertyWithSameNameShouldReturnFalse()
 {
     // Fixture setup
     var propertyName = "Field";
     var requestedName = "Field";
     var sut = new PropertySpecification(typeof(object), propertyName);
     var request = typeof(FieldHolder<object>).GetField(requestedName);
     // Exercise system
     var result = sut.IsSatisfiedBy(request);
     // Verify outcome
     Assert.False(result);
     // Teardown
 }
 public void IsSatisfiedByWithRequestForPropertyWithSameNameAndIncompatibleTypeShouldReturnFalse()
 {
     // Fixture setup
     var propertyName = "Property";
     var requestedName = "Property";
     var sut = new PropertySpecification(typeof(object), propertyName);
     var request = typeof(PropertyHolder<int>).GetProperty(requestedName);
     // Exercise system
     var result = sut.IsSatisfiedBy(request);
     // Verify outcome
     Assert.False(result);
     // Teardown
 }