Squadron

Squadron

  • Docs
  • Blog
  • GitHub

›Container Providers

Introduction

  • Introduction
  • Quickstart
  • Basic Concept
  • Container Options
  • Configuration
  • Multiple resources

Container Providers

  • MongoDB
  • MongoDB Replica Set
  • SQL Server
  • Elasticsearch
  • PostgreSQL
  • Redis
  • RabbitMQ
  • Azure Storage
  • Generic
  • Compose

Azure Cloud Providers

  • Setup
  • ServiceBus
Edit

Elasticsearch

Install

Install the Squadron nuget package for Elasticsearch within your test project:

dotnet add package Squadron.Elasticsearch

Access

Inject ElasticsearchResource into your test class constructor:

public class AccountRepositoryTests
    : IClassFixture<ElasticsearchResource>
{
    private readonly ElasticsearchResource _elasticsearchResource;

    public AccountRepositoryTests(
        ElasticsearchResource elasticsearchResource)
    {
        _elasticsearchResource = elasticsearchResource;
    }
}

Use

Use ElasticsearchResource to create a database and initialize your repository:

[Fact]
public async Task CreateAccount_AccountExists()
{
    // arrange
    var accountRepository = new AccountRepository(_elasticsearchResource.Client);
    var account = new Account();

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

    // assert
    Snapshot.Match(addedAccount);
}
Last updated on 10/5/2019 by Gabriel Lucaci
← SQL ServerPostgreSQL →
  • Install
  • Access
  • Use

Community

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