public void SutDoesNotEqualAnonymousObject()
        {
            // Arrange
            var    sut             = new RangedSequenceRequest(new object(), 10, 20);
            object anonymousObject = new ConcreteType();

            // Act
            var result = sut.Equals(anonymousObject);

            // Assert
            Assert.False(result, "Equals");
        }
        public void SutDoesNotEqualNullSut()
        {
            // Arrange
            var sut = new RangedSequenceRequest(new object(), 10, 20);
            RangedSequenceRequest other = null;

            // Act
            var result = sut.Equals(other);

            // Assert
            Assert.False(result, "Equals");
        }
        public void SutDoesNotEqualOtherObjectWhenRangeDifferButRequestMatches()
        {
            // Arrange
            var    request = new object();
            var    sut     = new RangedSequenceRequest(request, 10, 20);
            object other   = new RangedSequenceRequest(request, 1, 30);

            // Act
            var result = sut.Equals(other);

            // Assert
            Assert.False(result, "Equals");
        }
        public void SutDoesNotEqualOtherObjectWhenRequestsDifferButRangeMatches()
        {
            // Arrange
            var    min   = 10;
            var    max   = 10;
            var    sut   = new RangedSequenceRequest(new object(), min, max);
            object other = new RangedSequenceRequest(new object(), min, max);

            // Act
            var result = sut.Equals(other);

            // Assert
            Assert.False(result, "Equals");
        }
        public void SutEqualsOtherSutWhenBothRequestsAndRangeMatch()
        {
            // Arrange
            var request = new object();
            var min     = 10;
            var max     = 20;
            var sut     = new RangedSequenceRequest(request, min, max);
            var other   = new RangedSequenceRequest(request, min, max);

            // Act
            var result = sut.Equals(other);

            // Assert
            Assert.True(result, "Equals");
        }
        public void CreateWithRangedSequenceRequestConstrainedByMinAndMaxLengthReturnsCorrectResult(int min, int max)
        {
            // Arrange
            var memberType = typeof(string[]);

            var minLengthAttribute = new MinLengthAttribute(min);
            var maxLengthAttribute = new MaxLengthAttribute(max);
            var request            = new FakeMemberInfo(
                new ProvidedAttribute(minLengthAttribute, true),
                new ProvidedAttribute(maxLengthAttribute, true));

            var expectedRangedSequenceRequest = new RangedSequenceRequest(typeof(string), min, max);
            var expectedResult = new List <string>();

            var context = new DelegatingSpecimenContext
            {
                OnResolve = r =>
                {
                    if (expectedRangedSequenceRequest.Equals(r))
                    {
                        return(expectedResult);
                    }
                    return(new NoSpecimen());
                }
            };

            var sut = new MinAndMaxLengthAttributeRelay
            {
                RequestMemberTypeResolver = new DelegatingRequestMemberTypeResolver
                {
                    OnTryGetMemberType = r => memberType
                }
            };

            // Act
            var result = sut.Create(request, context);

            // Assert
            Assert.Equal(expectedResult, result);
        }