using AsbCloudApp.Services; using AsbCloudDb.Model; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Diagnostics; namespace AsbCloudWebApi.Tests { internal static class TestHelpter { // Попробовать когда-нибудь https://github.com/MichalJankowskii/Moq.EntityFrameworkCore public static AsbCloudDbContext MakeTestContext() { var options = new DbContextOptionsBuilder() //.UseInMemoryDatabase(System.Guid.NewGuid().ToString()) //.ConfigureWarnings(configBuilder => // configBuilder.Ignore(InMemoryEventId.TransactionIgnoredWarning)) .UseNpgsql("Host=localhost;Database=tests;Username=postgres;Password=q;Persist Security Info=True;Include Error Detail=True") .Options; var context = new AsbCloudDbContext(options); //context.Database.EnsureDeleted(); context.Database.EnsureCreated(); return context; } } }