public void SutIsRequestSpecification()
 {
     // Fixture setup
     // Exercise system
     var sut = new FieldSpecification(typeof(object), "someName");
     // Verify outcome
     Assert.IsAssignableFrom<IRequestSpecification>(sut);
     // Teardown
 }
 public void IsSatisfiedByWithNullRequestShouldThrowArgumentNullException()
 {
     // Fixture setup
     var sut = new FieldSpecification(typeof(object), "someName");
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() =>
         sut.IsSatisfiedBy(null));
     // Teardown
 }
 public void InitializeWithFieldNameShouldSetCorrespondingProperty()
 {
     // Fixture setup
     var type = typeof(string);
     var name = "someName";
     // Exercise system
     var sut = new FieldSpecification(type, name);
     // Verify outcome
     Assert.Equal(type, sut.TargetType);
     Assert.Equal(name, sut.TargetName);
     // Teardown
 }
 public void IsSatisfiedByWithRequestForFieldShouldReturnCorrectResult(
     string fieldName,
     string requestedName,
     bool expectedResult)
 {
     // Fixture setup
     var sut = new FieldSpecification(typeof(object), fieldName);
     var request = typeof(FieldHolder<object>).GetField(requestedName);
     // Exercise system
     var result = sut.IsSatisfiedBy(request);
     // Verify outcome
     Assert.Equal(expectedResult, result);
     // Teardown
 }
 public void IsSatisfiedByWithRequestForFieldWithSameNameAndIncompatibleTypeShouldReturnFalse()
 {
     // Fixture setup
     var sut = new FieldSpecification(typeof(object), "Field");
     var request = typeof(FieldHolder<string>).GetField("Field");
     // Exercise system
     var result = sut.IsSatisfiedBy(request);
     // Verify outcome
     Assert.False(result);
     // Teardown
 }
        public void IsSatisfiedByReturnsCorrectResultAccordingToTarget(
            bool expected)
        {
            var field = typeof(string).GetField("Empty");
            var target = new DelegatingCriterion<FieldInfo>
            {
                OnEquals = f =>
                {
                    Assert.Equal(field, f);
                    return expected;
                }
            };
            var sut = new FieldSpecification(target);

            var actual = sut.IsSatisfiedBy(field);

            Assert.Equal(expected, actual);
        }
 public void IsSatisfiedByWithInvalidRequestShouldReturnFalse(object request)
 {
     // Fixture setup
     var sut = new FieldSpecification(typeof(object), "someName");
     // Exercise system
     var result = sut.IsSatisfiedBy(request);
     // Verify outcome
     Assert.False(result);
     // Teardown
 }
 public void IsSatisfiedByWithRequestForMemberOtherThanFieldWithSameNameShouldReturnFalse()
 {
     // Fixture setup
     var sut = new FieldSpecification(typeof(object), "Property");
     var request = typeof(PropertyHolder<object>).GetProperty("Property");
     // Exercise system
     var result = sut.IsSatisfiedBy(request);
     // Verify outcome
     Assert.False(result);
     // Teardown
 }