AutoFixture - configure fixture to limit string generation length
问题 When using autofixture Build method for some type, how can I limit the length of the strings generated to fill that objects string properties/fields? 回答1: With the Build method itself, there aren't that many options, but you can do something like this: var constrainedText = fixture.Create<string>().Substring(0, 10); var mc = fixture .Build<MyClass>() .With(x => x.SomeText, constrainedText) .Create(); However, personally, I don't see how this is any better or easier to understand that this: