CaveTester.Bogus 1.0.0-beta2

Test data generation helper

This is a prerelease version of CaveTester.Bogus.
Install-Package CaveTester.Bogus -Version 1.0.0-beta2
dotnet add package CaveTester.Bogus --version 1.0.0-beta2
<PackageReference Include="CaveTester.Bogus" Version="1.0.0-beta2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CaveTester.Bogus --version 1.0.0-beta2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CaveTester.Bogus, 1.0.0-beta2"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install CaveTester.Bogus as a Cake Addin
#addin nuget:?package=CaveTester.Bogus&version=1.0.0-beta2&prerelease

// Install CaveTester.Bogus as a Cake Tool
#tool nuget:?package=CaveTester.Bogus&version=1.0.0-beta2&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Cave Tester

Cave Tester is a lightweight testing library that help you manage your database and generate mock data.

Features

  • Automatic database save and restore
  • Determinist id generator
  • Rules sets for object generation with Bogus

Planned features

  • Database pooling for easier parallel testing
  • Some methods to test entity ⇔ dto mapping

Quickstart

public class FooTests : Tester
{
	private readonly DbContext _dbContext;

	public FooTests()
	{
		// init your context here

		// Create a snapshot of the database before the test begin
		SaveHandler.Add(new SqlServerDbSnapshot(_dbContext.Database));
	}

	[Fact]
	public async Task ShouldFoo()
	{
		// Generate 5 Person with a random name
		await _dbContext.Generate<Person>(5, (faker, person) => person.Name = faker.Lorem.Word())
				 .SaveChangesAsync();

		// method to test
		// assertions

		// The database will automaticly be restored in a clean state from the snapeshot, wich will then be deleted
		// This happen even if the test fails
	}
}

public class Person
{
	public string Name { get; set; }
}

Example

See a complete example here

Tests

To build and run the tests you need to create a database using the script CaveTester.Tests/create_database.sql and configure the connection string CaveTester.Tests/DbSaverTests.cs

Cave Tester

Cave Tester is a lightweight testing library that help you manage your database and generate mock data.

Features

  • Automatic database save and restore
  • Determinist id generator
  • Rules sets for object generation with Bogus

Planned features

  • Database pooling for easier parallel testing
  • Some methods to test entity ⇔ dto mapping

Quickstart

public class FooTests : Tester
{
	private readonly DbContext _dbContext;

	public FooTests()
	{
		// init your context here

		// Create a snapshot of the database before the test begin
		SaveHandler.Add(new SqlServerDbSnapshot(_dbContext.Database));
	}

	[Fact]
	public async Task ShouldFoo()
	{
		// Generate 5 Person with a random name
		await _dbContext.Generate<Person>(5, (faker, person) => person.Name = faker.Lorem.Word())
				 .SaveChangesAsync();

		// method to test
		// assertions

		// The database will automaticly be restored in a clean state from the snapeshot, wich will then be deleted
		// This happen even if the test fails
	}
}

public class Person
{
	public string Name { get; set; }
}

Example

See a complete example here

Tests

To build and run the tests you need to create a database using the script CaveTester.Tests/create_database.sql and configure the connection string CaveTester.Tests/DbSaverTests.cs

Release Notes

Add SourceLink support
Add Jetbrain nullable attributes

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.0-beta2 384 11/30/2018
1.0.0-beta1 351 9/26/2018