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 }
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 }
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 }
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 }
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); }
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)); }