Exemple #1
0
        public void CreateWithFieldDecoratedWithRangeAttributeReturnsCorrectResult(
            Type attributeType,
            object attributeMinimum,
            object attributeMaximum)
        {
            // Fixture setup
            var  request = typeof(RangeValidatedType).GetField("Field");
            Type target  = request.FieldType;

            var expectedRequest = new RangedNumberRequest(
                target,
                Convert.ChangeType(RangeValidatedType.Minimum, target, CultureInfo.CurrentCulture),
                Convert.ChangeType(RangeValidatedType.Maximum, target, CultureInfo.CurrentCulture)
                );

            var expectedResult = new object();
            var context        = new DelegatingSpecimenContext
            {
                OnResolve = r => expectedRequest.Equals(r) ? expectedResult : new NoSpecimen(r)
            };
            var sut = new RangeAttributeRelay();
            // Exercise system
            var result = sut.Create(request, context);

            // Verify outcome
            Assert.Equal(expectedResult, result);
            // Teardown
        }
Exemple #2
0
        public void CreateWithRangeAttributeRequestReturnsCorrectResult(Type type, object minimum, object maximum)
        {
            // Fixture setup
            var rangeAttribute               = new RangeAttribute(type, minimum.ToString(), maximum.ToString());
            var providedAttribute            = new ProvidedAttribute(rangeAttribute, true);
            ICustomAttributeProvider request = new FakeCustomAttributeProvider(providedAttribute);
            Type conversionType              = rangeAttribute.OperandType;
            var  expectedRequest             = new RangedNumberRequest(
                conversionType,
                Convert.ChangeType(rangeAttribute.Minimum, conversionType, CultureInfo.CurrentCulture),
                Convert.ChangeType(rangeAttribute.Maximum, conversionType, CultureInfo.CurrentCulture)
                );
            var expectedResult = new object();
            var context        = new DelegatingSpecimenContext
            {
                OnResolve = r => expectedRequest.Equals(r) ? expectedResult : new NoSpecimen(r)
            };
            var sut = new RangeAttributeRelay();
            // Exercise system
            var result = sut.Create(request, context);

            // Verify outcome
            Assert.Equal(expectedResult, result);
            // Teardown
        }
Exemple #3
0
        public void CreateWithPropertyDecoratedWithRangeAttributeReturnsCorrectResult(
            string name,
            object attributeMinimum,
            object attributeMaximum)
        {
            // Fixture setup
            var  request = typeof(RangeValidatedType).GetProperty(name);
            Type target  = Nullable.GetUnderlyingType(request.PropertyType)
                           ?? request.PropertyType;

            var expectedRequest = new RangedNumberRequest(
                target,
                Convert.ChangeType(RangeValidatedType.Minimum, target, CultureInfo.CurrentCulture),
                Convert.ChangeType(RangeValidatedType.Maximum, target, CultureInfo.CurrentCulture)
                );

            var expectedResult = new object();
            var context        = new DelegatingSpecimenContext
            {
#pragma warning disable 618
                OnResolve = r => expectedRequest.Equals(r) ? expectedResult : new NoSpecimen(r)
#pragma warning restore 618
            };
            var sut = new RangeAttributeRelay();
            // Exercise system
            var result = sut.Create(request, context);

            // Verify outcome
            Assert.Equal(expectedResult, result);
            // Teardown
        }
        public void SutDoesNotEqualNullSut()
        {
            // Arrange
            var sut = new RangedNumberRequest(typeof(int), 1, 3);
            RangedNumberRequest other = null;
            // Act
            var result = sut.Equals(other);

            // Assert
            Assert.False(result, "Equals");
        }
        public void SutDoesNotEqualAnonymousObject()
        {
            // Arrange
            var    sut             = new RangedNumberRequest(typeof(int), 1, 3);
            object anonymousObject = new ConcreteType();
            // Act
            var result = sut.Equals(anonymousObject);

            // Assert
            Assert.False(result, "Equals");
        }
        public void SutDoesNotEqualOtherObjectWhenOperandTypesDiffer()
        {
            // Arrange
            var    sut   = new RangedNumberRequest(typeof(int), 1, 3);
            object other = new RangedNumberRequest(typeof(double), 1, 3);
            // Act
            var result = sut.Equals(other);

            // Assert
            Assert.False(result, "Equals");
        }
        public void SutDoesNotEqualOtherSutWhenMaximumsDiffer()
        {
            // Arrange
            var sut   = new RangedNumberRequest(typeof(int), 1, 3);
            var other = new RangedNumberRequest(typeof(int), 1, 4);
            // Act
            var result = sut.Equals(other);

            // Assert
            Assert.False(result, "Equals");
        }
Exemple #8
0
        public void SutDoesNotEqualNullSut()
        {
            // Fixture setup
            var sut = new RangedNumberRequest(typeof(int), 1, 3);
            RangedNumberRequest other = null;
            // Exercise system
            var result = sut.Equals(other);

            // Verify outcome
            Assert.False(result, "Equals");
            // Teardown
        }
Exemple #9
0
        public void SutDoesNotEqualOtherSutWhenMaximumsDiffer()
        {
            // Fixture setup
            var sut   = new RangedNumberRequest(typeof(int), 1, 3);
            var other = new RangedNumberRequest(typeof(int), 1, 4);
            // Exercise system
            var result = sut.Equals(other);

            // Verify outcome
            Assert.False(result, "Equals");
            // Teardown
        }
Exemple #10
0
        public void SutDoesNotEqualOtherObjectWhenOperandTypesDiffer()
        {
            // Fixture setup
            var    sut   = new RangedNumberRequest(typeof(int), 1, 3);
            object other = new RangedNumberRequest(typeof(double), 1, 3);
            // Exercise system
            var result = sut.Equals(other);

            // Verify outcome
            Assert.False(result, "Equals");
            // Teardown
        }
Exemple #11
0
        public void SutDoesNotEqualAnonymousObject()
        {
            // Fixture setup
            var    sut             = new RangedNumberRequest(typeof(int), 1, 3);
            object anonymousObject = new FileStyleUriParser();
            // Exercise system
            var result = sut.Equals(anonymousObject);

            // Verify outcome
            Assert.False(result, "Equals");
            // Teardown
        }
        public void SutEqualsOtherSutWhenConstructorParametersEquals()
        {
            // Arrange
            Type   operandType = typeof(int);
            object minimum     = 1;
            object maximum     = 3;
            var    sut         = new RangedNumberRequest(operandType, minimum, maximum);
            var    other       = new RangedNumberRequest(operandType, minimum, maximum);
            // Act
            var result = sut.Equals(other);

            // Assert
            Assert.True(result, "Equals");
        }
Exemple #13
0
        public void SutEqualsOtherSutWhenConstructorParametersEquals()
        {
            // Fixture setup
            Type   operandType = typeof(int);
            object minimum     = 1;
            object maximum     = 3;
            var    sut         = new RangedNumberRequest(operandType, minimum, maximum);
            var    other       = new RangedNumberRequest(operandType, minimum, maximum);
            // Exercise system
            var result = sut.Equals(other);

            // Verify outcome
            Assert.True(result, "Equals");
            // Teardown
        }
 public void SutEqualsOtherSutWhenConstructorParametersEquals()
 {
     // Fixture setup
     Type operandType = typeof(int);
     object minimum = 1;
     object maximum = 3;
     var sut = new RangedNumberRequest(operandType, minimum, maximum);
     var other = new RangedNumberRequest(operandType, minimum, maximum);
     // Exercise system
     var result = sut.Equals(other);
     // Verify outcome
     Assert.True(result, "Equals");
     // Teardown
 }
 public void SutDoesNotEqualAnonymousObject()
 {
     // Fixture setup
     var sut = new RangedNumberRequest(typeof(int), 1, 3);
     object anonymousObject = new FileStyleUriParser();
     // Exercise system
     var result = sut.Equals(anonymousObject);
     // Verify outcome
     Assert.False(result, "Equals");
     // Teardown
 }
 public void SutDoesNotEqualNullSut()
 {
     // Fixture setup
     var sut = new RangedNumberRequest(typeof(int), 1, 3);
     RangedNumberRequest other = null;
     // Exercise system
     var result = sut.Equals(other);
     // Verify outcome
     Assert.False(result, "Equals");
     // Teardown
 }
 public void SutDoesNotEqualOtherObjectWhenOperandTypesDiffer()
 {
     // Fixture setup
     var sut      = new RangedNumberRequest(typeof(int), 1, 3);
     object other = new RangedNumberRequest(typeof(double), 1, 3);
     // Exercise system
     var result = sut.Equals(other);
     // Verify outcome
     Assert.False(result, "Equals");
     // Teardown
 }
        public void CreateWithRangeAttributeRequestReturnsCorrectResult(Type type, object minimum, object maximum)
        {
            // Fixture setup
            var rangeAttribute = new RangeAttribute(type, minimum.ToString(), maximum.ToString());
            var providedAttribute = new ProvidedAttribute(rangeAttribute, true);
            ICustomAttributeProvider request = new FakeCustomAttributeProvider(providedAttribute);
            Type conversionType = rangeAttribute.OperandType;
            var expectedRequest = new RangedNumberRequest(
                conversionType,
                Convert.ChangeType(rangeAttribute.Minimum, conversionType, CultureInfo.CurrentCulture),
                Convert.ChangeType(rangeAttribute.Maximum, conversionType, CultureInfo.CurrentCulture)
                );
            var expectedResult = new object();
            var context = new DelegatingSpecimenContext
            {
#pragma warning disable 618
                OnResolve = r => expectedRequest.Equals(r) ? expectedResult : new NoSpecimen(r)
#pragma warning restore 618
            };
            var sut = new RangeAttributeRelay();
            // Exercise system
            var result = sut.Create(request, context);
            // Verify outcome
            Assert.Equal(expectedResult, result);
            // Teardown
        }
        public void CreateWithFieldDecoratedWithRangeAttributeReturnsCorrectResult(
            string name,
            object attributeMinimum,
            object attributeMaximum)
        {
            // Fixture setup
            var request = typeof(RangeValidatedType).GetField(name);
            Type target = Nullable.GetUnderlyingType(request.FieldType)
                ?? request.FieldType;

            var expectedRequest = new RangedNumberRequest(
                target,
                Convert.ChangeType(RangeValidatedType.Minimum, target, CultureInfo.CurrentCulture),
                Convert.ChangeType(RangeValidatedType.Maximum, target, CultureInfo.CurrentCulture)
                );

            var expectedResult = new object();
            var context = new DelegatingSpecimenContext
            {
#pragma warning disable 618
                OnResolve = r => expectedRequest.Equals(r) ? expectedResult : new NoSpecimen(r)
#pragma warning restore 618
            };
            var sut = new RangeAttributeRelay();
            // Exercise system
            var result = sut.Create(request, context);
            // Verify outcome
            Assert.Equal(expectedResult, result);
            // Teardown
        }
        public void CreateWithPropertyDecoratedWithRangeAttributeReturnsCorrectResult(
            Type attributeType, 
            object attributeMinimum, 
            object attributeMaximum)
        {
            // Fixture setup
            var request = typeof(RangeValidatedType).GetProperty("Property");
            Type target = request.PropertyType;

            var expectedRequest = new RangedNumberRequest(
                target,
                Convert.ChangeType(RangeValidatedType.Minimum, target, CultureInfo.CurrentCulture),
                Convert.ChangeType(RangeValidatedType.Maximum, target, CultureInfo.CurrentCulture)
                );
           
            var expectedResult = new object();
            var context = new DelegatingSpecimenContext
            {
                OnResolve = r => expectedRequest.Equals(r) ? expectedResult : new NoSpecimen(r)
            };
            var sut = new RangeAttributeRelay();
            // Exercise system
            var result = sut.Create(request, context);
            // Verify outcome
            Assert.Equal(expectedResult, result);
            // Teardown
        }
 public void SutDoesNotEqualOtherSutWhenMaximumsDiffer()
 {
     // Fixture setup
     var sut   = new RangedNumberRequest(typeof(int), 1, 3);
     var other = new RangedNumberRequest(typeof(int), 1, 4);
     // Exercise system
     var result = sut.Equals(other);
     // Verify outcome
     Assert.False(result, "Equals");
     // Teardown
 }