public void EqualsReturnsCorrectResult(
            bool typeResult,
            bool nameResult,
            bool expected)
        {
            var parameter =
                typeof(string).GetMethod("Contains").GetParameters().First();
            var typeCriterion = new DelegatingCriterion <Type>
            {
                OnEquals = t =>
                {
                    Assert.Equal(parameter.ParameterType, t);
                    return(typeResult);
                }
            };
            var nameCriterion = new DelegatingCriterion <string>
            {
                OnEquals = n =>
                {
                    Assert.Equal(parameter.Name, n);
                    return(nameResult);
                }
            };
            var sut =
                new ParameterTypeAndNameCriterion(
                    typeCriterion,
                    nameCriterion);

            var actual = sut.Equals(parameter);

            Assert.Equal(expected, actual);
        }
Example #2
0
        public void EqualsReturnsCorrectResult(
            bool typeResult,
            bool nameResult,
            bool expected)
        {
            var prop          = typeof(string).GetProperty("Length");
            var typeCriterion = new DelegatingCriterion <Type>
            {
                OnEquals = t =>
                {
                    Assert.Equal(prop.PropertyType, t);
                    return(typeResult);
                }
            };
            var nameCriterion = new DelegatingCriterion <string>
            {
                OnEquals = n =>
                {
                    Assert.Equal(prop.Name, n);
                    return(nameResult);
                }
            };
            var sut =
                new PropertyTypeAndNameCriterion(
                    typeCriterion,
                    nameCriterion);

            var actual = sut.Equals(prop);

            Assert.Equal(expected, actual);
        }
Example #3
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);
        }
Example #4
0
        public void NameCriterionIsCorrect()
        {
            var expected = new DelegatingCriterion <string>();
            var sut      = new PropertyTypeAndNameCriterion(
                new DelegatingCriterion <Type>(),
                expected);

            IEquatable <string> actual = sut.NameCriterion;

            Assert.Equal(expected, actual);
        }
        public void TypeCriterionIsCorrect()
        {
            var expected = new DelegatingCriterion <Type>();
            var sut      = new ParameterTypeAndNameCriterion(
                expected,
                new DelegatingCriterion <string>());

            IEquatable <Type> actual = sut.TypeCriterion;

            Assert.Equal(expected, actual);
        }
Example #6
0
        public void SutEqualsIdenticalValue()
        {
            var typeCriterion = new DelegatingCriterion <Type>();
            var nameCriterion = new DelegatingCriterion <string>();
            var sut           =
                new PropertyTypeAndNameCriterion(typeCriterion, nameCriterion);

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

            Assert.True(actual, "Expected structural equality to hold.");
        }
Example #7
0
        public void SutDoesNotEqualOtherWhenNameCriterionDiffers()
        {
            var typeCriterion = new DelegatingCriterion <Type>();
            var sut           = new PropertyTypeAndNameCriterion(
                typeCriterion,
                new DelegatingCriterion <string>());

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

            Assert.False(
                actual,
                "SUT should not equal other when name criterion differs.");
        }
Example #8
0
        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 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);
        }
Example #10
0
        public void IsSatisfiedByReturnsCorrectResultAccordingToTarget(
            bool expected)
        {
            var parameter =
                typeof(string).GetMethod("Contains", new[] { typeof(string) }).GetParameters().First();
            var target = new DelegatingCriterion <ParameterInfo>
            {
                OnEquals = f =>
                {
                    Assert.Equal(parameter, f);
                    return(expected);
                }
            };
            var sut = new ParameterSpecification(target);

            var actual = sut.IsSatisfiedBy(parameter);

            Assert.Equal(expected, actual);
        }