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 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 }