Skip to content

Getting Started

Michael Altmann edited this page Sep 21, 2016 · 10 revisions
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

Entity Class

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

Entity Settings

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

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.

Data Provider

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.

Repository

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.

Clone this wiki locally