fixes db testing context
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
@ -6,7 +7,7 @@ namespace test.Mandatory
|
||||
[Collection("Database")]
|
||||
[Trait("regres", "no")]
|
||||
[Trait("dev", "wip")]
|
||||
public class Database: IClassFixture<ServerSideFixture>
|
||||
public class Database: IClassFixture<ServerSideFixture>, IDisposable
|
||||
{
|
||||
ServerSideFixture _serverFixture;
|
||||
ITestOutputHelper output;
|
||||
@ -14,6 +15,8 @@ namespace test.Mandatory
|
||||
{
|
||||
this.output = output;
|
||||
_serverFixture = serverFixture;
|
||||
if (_serverFixture.DbCreated)
|
||||
_serverFixture.DropTestDb();
|
||||
|
||||
output.WriteLine($"Startup.DbSettings.Testing is {Startup.DbSettings.Testing}");
|
||||
}
|
||||
@ -25,11 +28,15 @@ namespace test.Mandatory
|
||||
[Fact]
|
||||
public void InstallFromScratchUsingPoweredNpgsqlUser()
|
||||
{
|
||||
if (_serverFixture.DbCreated)
|
||||
_serverFixture.DropTestDb();
|
||||
|
||||
_serverFixture.CreateTestDb();
|
||||
_serverFixture.UpgradeDb();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_serverFixture.DbCreated)
|
||||
_serverFixture.DropTestDb();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -82,9 +82,9 @@ namespace test
|
||||
_logger = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool DbCreated { get; private set; }
|
||||
|
||||
|
||||
//
|
||||
public ServerSideFixture()
|
||||
{
|
||||
@ -141,8 +141,6 @@ namespace test
|
||||
cx.Close();
|
||||
}
|
||||
}
|
||||
/* Needs a connection string parsing */
|
||||
|
||||
public void CreateTestDb()
|
||||
{
|
||||
if (!DbCreated)
|
||||
@ -157,6 +155,7 @@ namespace test
|
||||
_logger.LogInformation($"database created.");
|
||||
cx.Close();
|
||||
}
|
||||
DbCreated=true;
|
||||
}
|
||||
public void DropTestDb()
|
||||
{
|
||||
@ -171,7 +170,9 @@ namespace test
|
||||
_logger.LogInformation($"database dropped");
|
||||
cx.Close();
|
||||
}
|
||||
DbCreated=false;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Logger.LogInformation("Disposing");
|
||||
|
@ -29,14 +29,18 @@ namespace test
|
||||
|
||||
[Collection("Yavsc mandatory success story")]
|
||||
[Trait("regres", "no")]
|
||||
public class YavscMandatory: BaseTestContext, IClassFixture<ServerSideFixture>
|
||||
public class YavscMandatory: BaseTestContext, IClassFixture<ServerSideFixture>, IDisposable
|
||||
{
|
||||
|
||||
ApplicationDbContext _dbContext;
|
||||
ServerSideFixture _fixture;
|
||||
|
||||
public YavscMandatory(ITestOutputHelper output, ServerSideFixture fixture) : base (output, fixture)
|
||||
{
|
||||
_dbContext = fixture.DbContext;
|
||||
_fixture = fixture;
|
||||
if (!_fixture.DbCreated)
|
||||
_fixture.CreateTestDb();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -47,9 +51,12 @@ namespace test
|
||||
var di = new DirectoryInfo(_serverFixture.SiteSetup.GitRepository);
|
||||
if (!di.Exists) di.Create();
|
||||
|
||||
|
||||
var clone = new GitClone(_serverFixture.SiteSetup.GitRepository);
|
||||
clone.Launch(firstProject);
|
||||
gitRepo = di.FullName;
|
||||
}
|
||||
string gitRepo=null;
|
||||
|
||||
[Fact]
|
||||
void AnsiToHtml()
|
||||
@ -67,7 +74,6 @@ namespace test
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void MvcRazorHostAndParser()
|
||||
{
|
||||
@ -80,6 +86,7 @@ namespace test
|
||||
void HaveHost()
|
||||
{
|
||||
beforeCompileContext = CreateYavscCompilationContext();
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -186,5 +193,16 @@ namespace test
|
||||
IOptions<LocalizationOptions> localOptions = ActivatorUtilities.GetServiceOrCreateInstance<IOptions<LocalizationOptions>>(provider); ;
|
||||
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (gitRepo!=null)
|
||||
{
|
||||
Directory.Delete(Path.Combine(gitRepo,"yavsc"), true);
|
||||
}
|
||||
if (_fixture.DbCreated)
|
||||
_fixture.DropTestDb();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user