コード例 #1
0
        public void EqualsReturnsCorrectResult(
            bool typeResult,
            bool nameResult,
            bool expected)
        {
            var field         = typeof(string).GetField("Empty");
            var typeCriterion = new DelegatingCriterion <Type>
            {
                OnEquals = t =>
                {
                    Assert.Equal(field.FieldType, t);
                    return(typeResult);
                }
            };
            var nameCriterion = new DelegatingCriterion <string>
            {
                OnEquals = n =>
                {
                    Assert.Equal(field.Name, n);
                    return(nameResult);
                }
            };
            var sut =
                new FieldTypeAndNameCriterion(
                    typeCriterion,
                    nameCriterion);

            var actual = sut.Equals(field);

            Assert.Equal(expected, actual);
        }
コード例 #2
0
        public void EqualsReturnsCorrectResult(
            bool typeResult,
            bool nameResult,
            bool expected)
        {
            var field = typeof(string).GetField("Empty");
            var typeCriterion = new DelegatingCriterion<Type>
            {
                OnEquals = t =>
                {
                    Assert.Equal(field.FieldType, t);
                    return typeResult;
                }
            };
            var nameCriterion = new DelegatingCriterion<string>
            {
                OnEquals = n =>
                {
                    Assert.Equal(field.Name, n);
                    return nameResult;
                }
            };
            var sut =
                new FieldTypeAndNameCriterion(
                    typeCriterion,
                    nameCriterion);

            var actual = sut.Equals(field);

            Assert.Equal(expected, actual);
        }
コード例 #3
0
 public void SutIsFieldInfoEquatable()
 {
     var sut = new FieldTypeAndNameCriterion(
         new DelegatingCriterion<Type>(),
         new DelegatingCriterion<string>());
     Assert.IsAssignableFrom<IEquatable<FieldInfo>>(sut);
 }
コード例 #4
0
        public void SutIsFieldInfoEquatable()
        {
            var sut = new FieldTypeAndNameCriterion(
                new DelegatingCriterion <Type>(),
                new DelegatingCriterion <string>());

            Assert.IsAssignableFrom <IEquatable <FieldInfo> >(sut);
        }
コード例 #5
0
 public void SutDoesNotEqualNullFieldInfo()
 {
     var sut = new FieldTypeAndNameCriterion(
         new DelegatingCriterion<Type>(),
         new DelegatingCriterion<string>());
     var actual = sut.Equals((FieldInfo)null);
     Assert.False(actual, "SUT shouldn't equal null field.");
 }
コード例 #6
0
        public void SutDoesNotEqualNullFieldInfo()
        {
            var sut = new FieldTypeAndNameCriterion(
                new DelegatingCriterion <Type>(),
                new DelegatingCriterion <string>());
            var actual = sut.Equals((FieldInfo)null);

            Assert.False(actual, "SUT shouldn't equal null field.");
        }
コード例 #7
0
        public void SutDoesNotEqualAnyObject(object other)
        {
            var sut = new FieldTypeAndNameCriterion(
                new DelegatingCriterion <Type>(),
                new DelegatingCriterion <string>());
            var actual = sut.Equals(other);

            Assert.False(actual, "SUT should not equal object of other type.");
        }
コード例 #8
0
        public void NameCriterionIsCorrect()
        {
            var expected = new DelegatingCriterion <string>();
            var sut      = new FieldTypeAndNameCriterion(
                new DelegatingCriterion <Type>(),
                expected);

            IEquatable <string> actual = sut.NameCriterion;

            Assert.Equal(expected, actual);
        }
コード例 #9
0
        public void SutEqualsIdenticalValue()
        {
            var typeCriterion = new DelegatingCriterion <Type>();
            var nameCriterion = new DelegatingCriterion <string>();
            var sut           =
                new FieldTypeAndNameCriterion(typeCriterion, nameCriterion);

            var other =
                new FieldTypeAndNameCriterion(typeCriterion, nameCriterion);
            var actual = sut.Equals(other);

            Assert.True(actual, "Expected structural equality to hold.");
        }
コード例 #10
0
        public void SutDoesNotEqualOtherWhenNameCriterionDiffers()
        {
            var typeCriterion = new DelegatingCriterion <Type>();
            var sut           = new FieldTypeAndNameCriterion(
                typeCriterion,
                new DelegatingCriterion <string>());

            var other = new FieldTypeAndNameCriterion(
                typeCriterion,
                new DelegatingCriterion <string>());
            var actual = sut.Equals(other);

            Assert.False(
                actual,
                "SUT should not equal other when name criterion differs.");
        }
コード例 #11
0
        public void SutEqualsIdenticalValue()
        {
            var typeCriterion = new DelegatingCriterion<Type>();
            var nameCriterion = new DelegatingCriterion<string>();
            var sut =
                new FieldTypeAndNameCriterion(typeCriterion, nameCriterion);

            var other =
                new FieldTypeAndNameCriterion(typeCriterion, nameCriterion);
            var actual = sut.Equals(other);

            Assert.True(actual, "Expected structural equality to hold.");
        }
コード例 #12
0
        public void NameCriterionIsCorrect()
        {
            var expected = new DelegatingCriterion<string>();
            var sut = new FieldTypeAndNameCriterion(
                new DelegatingCriterion<Type>(),
                expected);

            IEquatable<string> actual = sut.NameCriterion;

            Assert.Equal(expected, actual);
        }
コード例 #13
0
        public void SutDoesNotEqualOtherWhenNameCriterionDiffers()
        {
            var typeCriterion = new DelegatingCriterion<Type>();
            var sut = new FieldTypeAndNameCriterion(
                typeCriterion,
                new DelegatingCriterion<string>());

            var other = new FieldTypeAndNameCriterion(
                typeCriterion,
                new DelegatingCriterion<string>());
            var actual = sut.Equals(other);

            Assert.False(
                actual,
                "SUT should not equal other when name criterion differs.");
        }
コード例 #14
0
 public void SutDoesNotEqualAnyObject(object other)
 {
     var sut = new FieldTypeAndNameCriterion(
         new DelegatingCriterion<Type>(),
         new DelegatingCriterion<string>());
     var actual = sut.Equals(other);
     Assert.False(actual, "SUT should not equal object of other type.");
 }