Squadron

Squadron

  • Docs
  • Blog
  • GitHub
Project Logo

A testing framework for containerized and cloud services

Get Started
Learn More

A framework to simplify your tests

Squadron is a helpful framework which enables you to write tests against dependent services without any overhead. Squadron can provide you isolation in tests through Container Providers or support for all other services through Cloud Providers.

  1. Install

Install the Squadron nuget package for MongoDB (or other supported service) within your test project:

dotnet add package Squadron.Mongo

  1. Access

Inject the MongoResource into your test class constructor:

public class AccountRepositoryTests
    : IClassFixture<MongoResource>
{
    private readonly MongoResource _mongoResource;

    public AccountRepositoryTests(
        MongoResource mongoResource)
    {
        _mongoResource = mongoResource;
    }
}

  1. Use

In your test use MongoResource to create a database and initialize your repository:

[Fact]
public void CreateAccount_AccountExists()
{
    // arrange
    var database = _mongoResource.CreateDatabase();
    var accountRepository = new AccountRepository(database);
    var account = new Account();

    // act
    var addedAccount = accountRepository.Add(account);

    // assert
    Snapshot.Match(addedAccount);
}

Community

Contributor License AgreementsCode of Conduct
Swiss Life OSSSwiss Life | OSS
Copyright © 2021 Swiss Life Developers