Closed CrahunGit closed 6 years ago
Hi @CrahunGit,
Thanks for letting me know. I have to admit I haven't used EF Core with .NET 4.7.1.
Can you add some example code to show what you need to do. I have linked this issue into the SQLite wiki page of this project.
Imagine a simple test like this:
public class EntityServiceTest
{
public EntityServiceTest()
{
//You need to call this on every test to work. If not exception tells you to call it
SQLitePCL.Batteries.Init();
}
[Fact]
public async Task GetEntities_AllActiveEntities_Returns1Entity()
{
//Arrange
DbContextOptions<EntidadContext> options = SqliteInMemory.CreateOptions<EntidadContext>();
Entity entity1 = new Entity { Id = 1, Name = "Entity 1", Active = "A"};
Entity entity2 = new Entity { Id = 2, Name = "Entity 2", Active = "D"};
using (EntityContext context = new EntityContext(options))
{
await SeedRangeDatabaseSameContext(context, new List<Entity>{ entity1, entity2 });
EntityRepository repository = new EntityRepository(context);
EntityService service = new EntityService(context, repository);
//Act
List<DtoEntity> entities = await service.GetEntities();
//Assert
entities.Should().HaveCount(1);
}
}
}
As the comment says you need to call init for the sqlite on every context using sqlite.
Thanks @CrahunGit - very helpful. I'm going to close this issue.
In .Net 4.7.1 you need to call the SQLitePCL.Batteries.Init() on the test initializer. In net core it works as expected.