forked from ddrilling/AsbCloudServer
27 lines
1.0 KiB
C#
27 lines
1.0 KiB
C#
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<AsbCloudDbContext>()
|
|
//.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;
|
|
}
|
|
}
|
|
}
|