// Copyright (c) 2020 Tudor Stanciu using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Tuitio.Application.Tests.Fixtures; using Tuitio.Domain.Data.DbContexts; using Xunit; namespace Tuitio.Application.Tests { public class LocalSqliteDatabaseTests : IClassFixture, IDisposable { private readonly IServiceScope _tuitioScope; public LocalSqliteDatabaseTests(DependencyInjectionFixture fixture) { _tuitioScope = fixture.ServiceProvider.GetRequiredService().CreateScope(); } public void Dispose() { _tuitioScope.Dispose(); } [Fact] public async Task EnsureExpectedDataInLocalDbTest() { // Arrange var _dbContext = _tuitioScope.ServiceProvider.GetRequiredService(); // Act var statuses = await _dbContext.UserStatuses.ToArrayAsync(); // Assert Assert.NotEmpty(statuses); Assert.True(statuses.All(z => !string.IsNullOrWhiteSpace(z.StatusCode))); Assert.Contains(statuses, z => z.StatusCode == "ACTIVE"); } } }