39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
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<DependencyInjectionFixture>, IDisposable
|
|
{
|
|
private readonly IServiceScope _tuitioScope;
|
|
|
|
public LocalSqliteDatabaseTests(DependencyInjectionFixture fixture)
|
|
{
|
|
_tuitioScope = fixture.ServiceProvider.GetRequiredService<IServiceScopeFactory>().CreateScope();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_tuitioScope.Dispose();
|
|
}
|
|
|
|
[Fact]
|
|
public async Task EnsureExpectedDataInLocalDbTest()
|
|
{
|
|
// Arrange
|
|
var _dbContext = _tuitioScope.ServiceProvider.GetRequiredService<TuitioDbContext>();
|
|
|
|
// 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");
|
|
}
|
|
}
|
|
}
|