Exemple #1
0
        public void CreateAnonymousWillSatisfyMaximumWhenHigh()
        {
            // Arrange
            var maximum = 89;
            var sut     = new ConstrainedStringGenerator(1, maximum);
            // Act
            var result = sut.CreateaAnonymous(string.Empty);

            // Assert
            Assert.True(result.Length <= maximum, "Length less than maximum");
        }
Exemple #2
0
        public void CreateAnonymousWillPrefixWithSeed()
        {
            // Arrange
            var seed = "Anonymous seed";
            var sut  = new ConstrainedStringGenerator(1, 100);
            // Act
            var result = sut.CreateaAnonymous(seed);

            // Assert
            Assert.StartsWith(seed, result);
        }
Exemple #3
0
        public void CreateAnonymousWillSatisfyMinimumWhenHigh()
        {
            // Arrange
            var minimum = 109;
            var sut     = new ConstrainedStringGenerator(minimum, 200);
            // Act
            string result = sut.CreateaAnonymous(string.Empty);

            // Assert
            Assert.True(result.Length >= minimum, "Length greater than minimum");
        }
Exemple #4
0
        public void CreateAnonymousWillSatisfyMaximumWhenHigh()
        {
            // Fixture setup
            var maximum = 89;
            var sut     = new ConstrainedStringGenerator(1, maximum);
            // Exercise system
            var result = sut.CreateaAnonymous(string.Empty);

            // Verify outcome
            Assert.True(result.Length <= maximum, "Length less than maximum");
            // Teardown
        }
Exemple #5
0
        public void CreateAnonymousWillSatisfyMinimumWhenHigh()
        {
            // Fixture setup
            var minimum = 109;
            var sut     = new ConstrainedStringGenerator(minimum, 200);
            // Exercise system
            string result = sut.CreateaAnonymous(string.Empty);

            // Verify outcome
            Assert.True(result.Length >= minimum, "Length greater than minimum");
            // Teardown
        }
Exemple #6
0
        public void CreateAnonymousWillPrefixWithSeed()
        {
            // Fixture setup
            var seed = "Anonymous seed";
            var sut  = new ConstrainedStringGenerator(1, 100);
            // Exercise system
            var result = sut.CreateaAnonymous(seed);

            // Verify outcome
            Assert.StartsWith(seed, result);
            // Teardown
        }
        public string CreateaAnonymous(string seed)
        {
            var s = string.Empty;

            while (s.Length < this.minimumLength)
            {
                s += ConstrainedStringGenerator.CreateAnonymous(seed);
            }
            if (s.Length > this.maximumLength)
            {
                s = s.Substring(0, this.maximumLength);
            }
            return(s);
        }
Exemple #8
0
        public static IPostprocessComposer <T> With <T>(
            this ICustomizationComposer <T> ob,
            Expression <Func <T, string> > propertyPicker,
            int minimumLength,
            int maximumLength)
        {
            var me        = (MemberExpression)propertyPicker.Body;
            var name      = me.Member.Name;
            var generator =
                new ConstrainedStringGenerator(
                    minimumLength, maximumLength);
            var value = generator.CreateaAnonymous(name);

            return(ob.With(propertyPicker, value));
        }