目前发现2个:
请求那个更好用?
AutoBogus 的简单使用:
var faker = new AutoFaker<BlogPost>();
faker.Configure(builder => builder.WithTreeDepth(1));
faker.RuleFor(p => p.Id, 0)
.RuleFor(p => p.PostType, PostType.BlogPost)
.RuleFor(p => p.IsActive, true)
.RuleFor(post => post.IsMarkdown, true)
.RuleFor(p => p.EntryName, Guid.NewGuid().ToString());
var postWithSlugUrl = faker.Generate();
AutoFixture 的简单使用
var fixture = new Fixture();
fixture.Behaviors.Add(new OmitOnRecursionBehavior());
var postWithSlugUrl = fixture.Build<BlogPost>()
.Without(p => p.Id)
.With(p => p.PostType, PostType.BlogPost)
.With(p => p.IsActive, true)
.With(post => post.IsMarkdown, true)
.With(p => p.EntryName, Guid.NewGuid().ToString())
.Create();