-
Notifications
You must be signed in to change notification settings - Fork 5
Getting Started
var config = new CherrySeedConfiguration(cfg =>
{
// set data provider
cfg.WithDataProvider(new CsvDataProvider());
// set repository
cfg.WithGlobalRepository(new EfRepository());
// set entity specific settings
cfg.ForEntity<Person>()
.WithPrimaryKey(e => e.Identification);
});
var cherrySeeder = config.CreateSeeder();
cherrySeeder.Seed();
CherrySeed requires five things to work properly:
- Entity Class
- Entity Settings
- Test Data
- Data Provider
- Repository
The entity class defines entity name and entity field names. Usually you don’t have to create this entity class specifically for CherrySeed because you are already using it in your application.
public class Person
{
public int Identification { get; set; }
public string Name { get; set; }
public DateTime Birthdate { get; set; }
}
With entity settings metadata is added to the entity. You define which field is the primary key, which fields are foreign keys, etc. For more info see Entity Settings.
Test data is the data which is inserted into the database. For example the entity Person with its fields Name “Julia” and Birthdate 1990/01/01. This is your main work to create valid and good test data. For more info see Defining Test Data.
The data provider defines the way how test data is loaded and defined. Whether test data comes from a csv/json/xml file or is declared directly in C# code depends on the data provider. For more info see Data Provider.
The repository is responsible for storing test data in the database. Whether Entity Framework, Hibernate or another O/R mapping framework is used depends on the repository. For more info see Repository.