Skip to content

Repository files navigation

I recommend using AutoFixture rather than this

Have cleaned up generating and dependencies Now supporting profile cloning. However you could still break it with silly use of expressions.

examples are in the tests

Can now create big graphs and mix/match and modify them.

Available on NuGet - https://nuget.org/packages/TestData.Profiles

varroles=newDataProfile<Role>(()=>newRole()).ForMember(x =>x.Id,(r)=>Guid.NewGuid()).GenerateForEach(_dataConfiguration,_roleNames,(name,role)=>role.Name=name).ToList();varproducts=newDataProfile<Product>(()=>newProduct()).ForMember(x =>x.Id,(r)=>Guid.NewGuid()).ForMember(x=>x.Amount,newDecimalRandomValueCreator(5,500)).GenerateForEach(_dataConfiguration,_productNames,(name,product)=>product.Name=name).ToList();_dataConfiguration=newDataConfiguration();_dataConfiguration.CreateProfileFor(()=>newOrderItem()).ForMember(x =>x.Product,newCollectionItemValueCreator<Product>(products)).ForMember(x =>x.Quantity,newIntRandomValueCreator(1,10));_dataConfiguration.CreateProfileFor(()=>newOrder()).ForMember(x =>x.CreatedOn,(x)=>DateTime.UtcNow).FollowPath(x =>x.Items,1,(o)=>newOrderItem(o));_dataConfiguration.CreateProfileFor(()=>newUser()).FollowPath(x =>x.Role).ForMember(x =>x.Id,(u)=>Guid.NewGuid()).ForMember(x =>x.FirstName,newRandomStringValueCreator(4,8)).ForMember(x =>x.Surname,newCollectionItemValueCreator<string>(_names)).ForMember(x =>x.Role,newCollectionItemValueCreator<Role>(roles)).ForMember(x =>x.LogonCount,newIntRandomValueCreator(1,200)).FollowPath(x =>x.Orders,3,200,(u)=>newOrder(u));

Note self referencing follow paths will cause a stackoverflow.

About

Test data generator suitable for unit testing

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages