Skip to content

Instantly share code, notes, and snippets.

Last active June 3, 2020 21:45
What would you like to do?
Example of a efficient test
using System;
using System.Threading.Tasks;
using Xunit;
using Bogus;
using AutoBogus;
using FluentAssertions;
using Squadron;
namespace Tests
public class PersistenceTest : IClassFixture<MongoResource>
private readonly Repository _repository;
private readonly IAutoFaker _fuzzer = AutoFaker.Create();
public PersistenceTest(MongoResource mongoResource)
Randomizer.Seed = new Random(42);
_repository = new Repository(mongoResource.CreateDatabase());
public async Task Add_Retrieve_Equivalent()
// Arrange
DomainModel model = _fuzzer.Generate<DomainModel>();
await _repository.AddAsync(model);
// Act
DomainModel result = await _repository.GetAsync(model.Id);
// Assert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment