コード例 #1
0
 public void CreateAnonymousWillSatisfyMaximumWhenLow()
 {
     // Fixture setup
     var maximum = 10;
     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
 }
コード例 #2
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
 }
コード例 #3
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.True(result.StartsWith(seed));
     // Teardown
 }
コード例 #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
        }
コード例 #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
        }
コード例 #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.True(result.StartsWith(seed));
            // Teardown
        }
コード例 #7
0
        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);
        }
コード例 #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));
        }