Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikus1993 committed Jan 27, 2024
1 parent 4232705 commit 8b8c792
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using AutoFixture.Xunit2;
using XboxPromotionCheckerBot.App.Core.Repositories;
using XboxPromotionCheckerBot.App.Core.Types;
using XboxPromotionCheckerBot.App.Tests.Infrastructure.Fixtures;

Expand All @@ -7,27 +8,40 @@ namespace XboxPromotionCheckerBot.App.Tests.Infrastructure.Repositories;
public class MongoGamesRepositoryTests : IClassFixture<MongoDbFixture>
{
private readonly MongoDbFixture _mongoDbFixture;

private readonly IGamesRepository _gamesRepository;
public MongoGamesRepositoryTests(MongoDbFixture mongoDbFixture)
{
_mongoDbFixture = mongoDbFixture;
_gamesRepository = _mongoDbFixture.MongoGamesRepository;
}

[Theory]
[AutoData]
public async Task TestWhenRecordNotExists(XboxGame game)
{
var exists = await _mongoDbFixture.MongoGamesRepository.Exists(game);
var exists = await _gamesRepository.Exists(game);
Assert.False(exists);
}

[Theory]
[AutoData]
public async Task TestWhenRecordExists(XboxGame game)
{
await _mongoDbFixture.MongoGamesRepository.Insert(game);
await _gamesRepository.Insert(game);

var exists = await _gamesRepository.Exists(game);
Assert.True(exists);
}

[Theory]
[AutoData]
public async Task TestInsertManyAndSearchWhenRecordExists(XboxGame[] games)
{
await _gamesRepository.Insert(games);

var randGame = Random.Shared.GetItems(games, 1).First();

var exists = await _mongoDbFixture.MongoGamesRepository.Exists(game);
var exists = await _gamesRepository.Exists(randGame);
Assert.True(exists);
}
}

0 comments on commit 8b8c792

Please sign in to comment.