Skip to content

CSV Data Provider

Michael Altmann edited this page Sep 21, 2016 · 5 revisions

Description

This extension is a data provider for CherrySeed which defines and loads test data from CSV files.

Installation

Install CSV Data Provider via NuGet.

Defining Test Data

You have to define one CSV file per entity. The name of the CSV file have to match with the entity name. How to Have a Match? For example the CSV file name is 'Person.csv' and the entity class name is 'Person'.

Within the CSV file the entity fields have to be defined in the first row. All the test data have to be defined starting second row.

Configuration

This extension provide some configurations which can set via class CsvDataProviderConfiguration:

Setting Name Description Default Value Example
FolderPath Folder path containing CSV files "C:\Temp\TestData\"
CsvFilePaths List of CSV file paths "C:\Temp\TestData\Person.csv"
Delimiter Delimiter separating values in CSV files ";" ","

How To Use It

This code block initiates a CSV data provider and sets it globally in CherrySeed.

var csvDataProviderConfiguration = new CsvDataProviderConfiguration() 
{
    FolderPath = "C:\Temp\TestData\",
    Delimiter = ","
};

var csvDataProvider = new CsvDataProvider(csvDataProviderConfiguration);

var config = new CherrySeedConfiguration(cfg =>
{
    ...
    cfg.WithDataProvider(csvDataProvider);
    ...
});

Changelog

v1.0.1

  • Initial version

Clone this wiki locally