vnext
Paul Schneider 3 years ago
parent 6ae7333dbb
commit 43c6f31a65
20 changed files with 175 additions and 140 deletions

@ -1,12 +1,3 @@
# using the official mono docker image to build a visual studio project.
#
# MyProject.sln
# MyProject\
# MyProject\
# MyProject.csproj (console application)
# MyProject.Test\
# MyProject.Test.csproj (test library using nuget packages "NUnit" and "NUnit.ConsoleRunner")
#
# Please find the full example project here: # Please find the full example project here:
# https://gitlab.com/tobiaskoch/gitlab-ci-example-mono # https://gitlab.com/tobiaskoch/gitlab-ci-example-mono
@ -34,9 +25,9 @@ before_script:
debug: debug:
stage: test stage: test
script: script:
- cd src/test - cd test/yavscTests
- dnu build - dnu build
- dnx test -maxthreads 1 -trait regression=non - ASPNET_ENV=Testing dnx test -maxthreads 1
release: release:
stage: deploy stage: deploy

@ -3,17 +3,18 @@ BINTARGET=bin/$(CONFIGURATION)/dnx451/test.dll
SOURCE_DIR=../.. SOURCE_DIR=../..
MAKEFILE_DIR=$(SOURCE_DIR)/scripts/make MAKEFILE_DIR=$(SOURCE_DIR)/scripts/make
MSBUILD=msbuild MSBUILD=msbuild
YAVSCSRC=../../src
include $(MAKEFILE_DIR)/dnx.mk include $(MAKEFILE_DIR)/dnx.mk
../Yavsc/bin/$(CONFIGURATION)/dnx451/Yavsc.dll: $(YAVSCSRC)/Yavsc/bin/$(CONFIGURATION)/dnx451/Yavsc.dll:
make -C ../Yavsc make -C $(YAVSCSRC)/Yavsc
../Yavsc.Abstract/bin/$(CONFIGURATION)/dnx451/Yavsc.Abstract.dll: $(YAVSCSRC)/Yavsc.Abstract/bin/$(CONFIGURATION)/dnx451/Yavsc.Abstract.dll:
make -C ../Yavsc.Abstract make -C $(YAVSCSRC)/Yavsc.Abstract
../Yavsc.Server/bin/$(CONFIGURATION)/dnx451/Yavsc.Server.dll: $(YAVSCSRC)/Yavsc.Server/bin/$(CONFIGURATION)/dnx451/Yavsc.Server.dll:
make -C ../Yavsc.Server make -C $(YAVSCSRC)/Yavsc.Server
$(BINTARGET): project.lock.json ../Yavsc/bin/$(CONFIGURATION)/dnx451/Yavsc.dll ../Yavsc.Abstract/bin/$(CONFIGURATION)/dnx451/Yavsc.Abstract.dll ../Yavsc.Server/bin/$(CONFIGURATION)/dnx451/Yavsc.Server.dll $(BINTARGET): project.lock.json $(YAVSCSRC)/Yavsc/bin/$(CONFIGURATION)/dnx451/Yavsc.dll $(YAVSCSRC)/Yavsc.Abstract/bin/$(CONFIGURATION)/dnx451/Yavsc.Abstract.dll $(YAVSCSRC)/Yavsc.Server/bin/$(CONFIGURATION)/dnx451/Yavsc.Server.dll
dnu build --configuration $(CONFIGURATION) dnu build --configuration $(CONFIGURATION)

@ -4,7 +4,7 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.PlatformAbstractions; using Microsoft.Extensions.PlatformAbstractions;
using Xunit.Abstractions; using Xunit.Abstractions;
namespace test namespace yavscTests
{ {
public class BaseTestContext { public class BaseTestContext {

@ -3,30 +3,34 @@ BINTARGET=bin/$(CONFIGURATION)/dnx451/test.dll
SOURCE_DIR=../.. SOURCE_DIR=../..
MAKEFILE_DIR=$(SOURCE_DIR)/scripts/make MAKEFILE_DIR=$(SOURCE_DIR)/scripts/make
MSBUILD=msbuild MSBUILD=msbuild
YAVSCSRC=../../src
all: test all: test
include $(MAKEFILE_DIR)/dnx.mk include $(MAKEFILE_DIR)/dnx.mk
../Yavsc/bin/$(CONFIGURATION)/dnx451/Yavsc.dll: $(YAVSCSRC)/Yavsc/bin/$(CONFIGURATION)/dnx451/Yavsc.dll:
make -C ../Yavsc make -C $(YAVSCSRC)/Yavsc
../Yavsc.Abstract/bin/$(CONFIGURATION)/dnx451/Yavsc.Abstract.dll: $(YAVSCSRC)/Yavsc.Abstract/bin/$(CONFIGURATION)/dnx451/Yavsc.Abstract.dll:
make -C ../Yavsc.Abstract make -C $(YAVSCSRC)/Yavsc.Abstract
../Yavsc.Server/bin/$(CONFIGURATION)/dnx451/Yavsc.Server.dll: $(YAVSCSRC)/Yavsc.Server/bin/$(CONFIGURATION)/dnx451/Yavsc.Server.dll:
make -C ../Yavsc.Server make -C $(YAVSCSRC)/Yavsc.Server
$(BINTARGET): project.lock.json ../Yavsc/bin/$(CONFIGURATION)/dnx451/Yavsc.dll ../Yavsc.Abstract/bin/$(CONFIGURATION)/dnx451/Yavsc.Abstract.dll ../Yavsc.Server/bin/$(CONFIGURATION)/dnx451/Yavsc.Server.dll $(BINTARGET): project.lock.json $(YAVSCSRC)/Yavsc/bin/$(CONFIGURATION)/dnx451/Yavsc.dll $(YAVSCSRC)/Yavsc.Abstract/bin/$(CONFIGURATION)/dnx451/Yavsc.Abstract.dll $(YAVSCSRC)/Yavsc.Server/bin/$(CONFIGURATION)/dnx451/Yavsc.Server.dll
dnu build --configuration $(CONFIGURATION) dnu build --configuration $(CONFIGURATION)
non-regression: $(BINTARGET) non-regression: $(BINTARGET)
ASPNET_ENV=Development dnx test -maxthreads 1 -trait regression=non ASPNET_ENV=Development dnx test -maxthreads 1 -trait regression=non
all-tests: $(BINTARGET)
ASPNET_ENV=Testing dnx test -maxthreads 1
regression: $(BINTARGET) regression: $(BINTARGET)
ASPNET_ENV=Development dnx test -maxthreads 1 -trait regression=oui ASPNET_ENV=Testing dnx test -maxthreads 1 -trait regression=oui
test: non-regression test: all-tests
testdev: $(BINTARGET) testdev: $(BINTARGET)
ASPNET_ENV=Development dnx test -maxthreads 1 -trait dev=wip ASPNET_ENV=Development dnx test -maxthreads 1 -trait dev=wip

@ -22,26 +22,27 @@ using Xunit.Abstractions;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using Yavsc.Server.Models.IT.SourceCode; using Yavsc.Server.Models.IT.SourceCode;
using yavscTests.Settings;
namespace test namespace yavscTests
{ {
[Collection("Yavsc mandatory success story")] [Collection("Yavsc mandatory success story")]
[Trait("regression", "oui")] [Trait("regression", "oui")]
public class BatchTests: BaseTestContext, IClassFixture<ServerSideFixture>, IDisposable public class BatchTests: BaseTestContext, IClassFixture<ServerSideFixture>, IDisposable
{ {
ServerSideFixture _fixture; private TestingSetup _testingOptions;
public BatchTests(ITestOutputHelper output, ServerSideFixture fixture) : base (output, fixture) public BatchTests(ITestOutputHelper output, ServerSideFixture fixture) : base (output, fixture)
{ {
_fixture = fixture; _testingOptions = fixture.TestingSetup;
} }
[Fact] [Fact]
public void GitClone() public void GitClone()
{ {
Assert.True(_serverFixture.EnsureTestDb()); Assert.True(_serverFixture.EnsureTestDb());
Assert.NotNull (_fixture.DbContext.Project); Assert.NotNull (_serverFixture.DbContext.Project);
var firstProject = _fixture.DbContext.Project.Include(p=>p.Repository).FirstOrDefault(); var firstProject = _serverFixture.DbContext.Project.Include(p=>p.Repository).FirstOrDefault();
Assert.NotNull (firstProject); Assert.NotNull (firstProject);
var di = new DirectoryInfo(_serverFixture.SiteSetup.GitRepository); var di = new DirectoryInfo(_serverFixture.SiteSetup.GitRepository);
if (!di.Exists) di.Create(); if (!di.Exists) di.Create();
@ -94,19 +95,32 @@ namespace test
configurationRoot = builder.Build(); configurationRoot = builder.Build();
} }
internal static BeforeCompileContext CreateYavscCompilationContext() internal BeforeCompileContext CreateYavscCompilationContext()
{ {
BeforeCompileContext newBeforeCompileContext = null;
Assert.NotNull(_testingOptions);
try
{
var projectContext = new ProjectContext var projectContext = new ProjectContext
{ {
Name = "Yavsc", Name = "Yavsc",
ProjectDirectory = "../Yavsc", ProjectDirectory = _testingOptions.YavscWebPath,
ProjectFilePath = "../Yavsc/project.json", ProjectFilePath = Path.Combine(_testingOptions.YavscWebPath, "project.json"),
TargetFramework = new FrameworkName("DNX", new Version(4, 5, 1)), TargetFramework = new FrameworkName("DNX", new Version(4, 5, 1)),
Configuration = Environment.GetEnvironmentVariable("ASPNET_ENV") Configuration = Environment.GetEnvironmentVariable("ASPNET_ENV")
}; };
return new BeforeCompileContext( newBeforeCompileContext = new BeforeCompileContext(
null, projectContext, () => null, () => null, () => null); null, projectContext, () => null, () => null, () => null);
}
catch(Exception ex)
{
_output.WriteLine(ex.Message);
_output.WriteLine(ex.StackTrace);
}
return newBeforeCompileContext;
} }
internal static IConfigurationRoot CreateConfiguration(string prjDir) internal static IConfigurationRoot CreateConfiguration(string prjDir)
@ -144,19 +158,21 @@ namespace test
{ {
options.ResourcesPath = "Resources"; options.ResourcesPath = "Resources";
}); });
AppDomain.CurrentDomain.SetData("YAVSC_DB_CONNECTION", Startup.Testing.ConnectionStrings.Default); AppDomain.CurrentDomain.SetData("YAVSC_DB_CONNECTION", Startup.TestingSetup.ConnectionStrings.Default);
serviceCollection.AddEntityFramework() serviceCollection.AddEntityFramework()
.AddNpgsql() .AddNpgsql()
.AddDbContext<ApplicationDbContext>( .AddDbContext<ApplicationDbContext>(
db => db.UseNpgsql(Startup.Testing.ConnectionStrings.Default) db => db.UseNpgsql(Startup.TestingSetup.ConnectionStrings.Default)
); );
provider = serviceCollection.BuildServiceProvider(); provider = serviceCollection.BuildServiceProvider();
} }
// TODO
[Fact] [Fact]
public void ARequestAppDelegate() public void ARequestDelegate()
{ {
try {
var services = new ServiceCollection(); var services = new ServiceCollection();
services.AddTransient<IRuntimeEnvironment>( services.AddTransient<IRuntimeEnvironment>(
svs => PlatformServices.Default.Runtime svs => PlatformServices.Default.Runtime
@ -169,12 +185,19 @@ namespace test
IApplicationBuilder app = new ApplicationBuilder(serviceProvider); IApplicationBuilder app = new ApplicationBuilder(serviceProvider);
var rtd = app.Build(); var rtd = app.Build();
}
catch (Exception ex)
{
_output.WriteLine(ex.Message);
_output.WriteLine(ex.StackTrace);
}
} }
[Fact] [Fact]
public void InitApplicationBuilder() public void InitApplicationBuilder()
{ {
try {
var services = new ServiceCollection(); var services = new ServiceCollection();
services.AddTransient<IRuntimeEnvironment>( services.AddTransient<IRuntimeEnvironment>(
@ -189,6 +212,17 @@ namespace test
var rtd = app.Build(); var rtd = app.Build();
IOptions<LocalizationOptions> localOptions = ActivatorUtilities.GetServiceOrCreateInstance<IOptions<LocalizationOptions>>(provider); ; IOptions<LocalizationOptions> localOptions = ActivatorUtilities.GetServiceOrCreateInstance<IOptions<LocalizationOptions>>(provider); ;
}
catch (Exception ex)
{
_output.WriteLine(ex.Message);
_output.WriteLine(ex.StackTrace);
}
finally
{
}
} }
public void Dispose() public void Dispose()
@ -197,7 +231,7 @@ namespace test
{ {
Directory.Delete(Path.Combine(gitRepo,"yavsc"), true); Directory.Delete(Path.Combine(gitRepo,"yavsc"), true);
} }
_fixture.DropTestDb(); _serverFixture.DropTestDb();
} }
} }
} }

@ -19,7 +19,7 @@ using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.Filters; using Microsoft.AspNet.Mvc.Filters;
using Microsoft.AspNet.Mvc.Razor; using Microsoft.AspNet.Mvc.Razor;
namespace test namespace yavscTests
{ {
[Collection("Yavsc Work In Progress")] [Collection("Yavsc Work In Progress")]
[Trait("regression", "oui")] [Trait("regression", "oui")]
@ -35,11 +35,6 @@ namespace test
[Fact] [Fact]
public void EnsureWeb() public void EnsureWeb()
{ {
var host = new WebHostBuilder();
host.UseEnvironment("Development")
.UseServer("Microsoft.AspNet.Server.Kestrel")
.UseStartup<test.Startup>()
.Build().Start();
} }
} }

@ -10,13 +10,14 @@ using System.Net;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Hosting;
using Microsoft.Extensions.OptionsModel;
using Microsoft.Extensions.PlatformAbstractions; using Microsoft.Extensions.PlatformAbstractions;
using Xunit; using Xunit;
using Xunit.Abstractions; using Xunit.Abstractions;
using Yavsc.Authentication; using Yavsc.Authentication;
using static OAuth.AspNet.AuthServer.Constants; using static OAuth.AspNet.AuthServer.Constants;
namespace test namespace yavscTests
{ {
[Collection("Yavsc Work In Progress")] [Collection("Yavsc Work In Progress")]
[Trait("regression", "oui")] [Trait("regression", "oui")]
@ -39,9 +40,7 @@ namespace test
string scope, string scope,
string authorizeUrl, string authorizeUrl,
string redirectUrl, string redirectUrl,
string accessTokenUrl, string accessTokenUrl
string login,
string pass
) )
{ {
try try
@ -52,8 +51,8 @@ namespace test
new Uri(authorizeUrl), new Uri(redirectUrl), new Uri(accessTokenUrl)); new Uri(authorizeUrl), new Uri(redirectUrl), new Uri(accessTokenUrl));
var query = new Dictionary<string, string> var query = new Dictionary<string, string>
{ {
[Parameters.Username] = Startup.Testing.ValidCreds[0].UserName, [Parameters.Username] = Startup.TestingSetup.ValidCreds.UserName,
[Parameters.Password] = Startup.Testing.ValidCreds[0].Password, [Parameters.Password] = Startup.TestingSetup.ValidCreds.Password,
[Parameters.GrantType] = GrantTypes.Password [Parameters.GrantType] = GrantTypes.Password
}; };
@ -70,7 +69,7 @@ namespace test
var webex = ex as WebException; var webex = ex as WebException;
if (webex != null && webex.Status == (WebExceptionStatus)400) if (webex != null && webex.Status == (WebExceptionStatus)400)
{ {
if (login == "joe") if (Startup.TestingSetup.ValidCreds.UserName == "lame-user")
{ {
Console.WriteLine("Bad pass joe!"); Console.WriteLine("Bad pass joe!");
return; return;
@ -85,30 +84,20 @@ namespace test
var allData = new List<object[]>(); var allData = new List<object[]>();
for (int iTest=0; iTest < numTests && iTest < Startup.Testing.ValidCreds.Length; iTest++)
{
var login = Startup.Testing.ValidCreds[iTest].UserName; allData.Add(new object[] { "blouh", "profile",
var pass = Startup.Testing.ValidCreds[iTest].Password; "http://localhost:5000/authorize", "http://localhost:5000/oauth/success",
"http://localhost:5000/token", "http://localhost:5000/authorize"});
allData.Add(new object[] { ServerSideFixture.ApiKey, "blouh", "profile",
"http://localhost:5000/authorize", "http://localhost:5000/oauth/success",
"http://localhost:5000/token",login, pass});
}
var valid = allData.Count;
for (int iTest=0; iTest + valid < numTests && iTest < Startup.Testing.InvalidCreds.Length; iTest++)
{
var login = Startup.Testing.InvalidCreds[iTest].UserName;
var pass = Startup.Testing.InvalidCreds[iTest].Password;
allData.Add(new object[] { ServerSideFixture.ApiKey, "blouh", "profile",
"http://localhost:5000/authorize", "http://localhost:5000/oauth/success",
"http://localhost:5000/token",login, 0 });
}
return allData.Take(numTests);
} allData.Add(new object[] { "blouh", "profile",
"http://localhost:5000/authorize", "http://localhost:5000/oauth/success",
"http://localhost:5000/token", "http://localhost:5000/authorize"});
return allData.Take(numTests);;
}
} }
} }

@ -1,5 +1,5 @@
namespace test { namespace yavscTests {
public class ResxResources { public class ResxResources {
const string resPath = "Resources/Test.TestResources.resx"; const string resPath = "Resources/Test.TestResources.resx";
public void HaveAResxLoader() public void HaveAResxLoader()

@ -10,11 +10,11 @@ using Yavsc;
using Yavsc.Models; using Yavsc.Models;
using Xunit; using Xunit;
using Npgsql; using Npgsql;
using test.Settings;
using Microsoft.Data.Entity; using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Metadata.Conventions; using Microsoft.Data.Entity.Metadata.Conventions;
using yavscTests.Settings;
namespace test namespace yavscTests
{ {
[Trait("regression", "II")] [Trait("regression", "II")]
public class ServerSideFixture : IDisposable public class ServerSideFixture : IDisposable
@ -26,7 +26,7 @@ namespace test
readonly ILoggerFactory _loggerFactory; readonly ILoggerFactory _loggerFactory;
IEmailSender _mailSender; IEmailSender _mailSender;
public static string ApiKey => "53f4d5da-93a9-4584-82f9-b8fdf243b002"; public string ApiKey { get; private set; }
public ApplicationDbContext DbContext { get; private set; } public ApplicationDbContext DbContext { get; private set; }
public SiteSettings SiteSetup public SiteSettings SiteSetup
@ -46,7 +46,7 @@ namespace test
/// initialized by Init /// initialized by Init
/// </summary> /// </summary>
/// <value></value> /// <value></value>
public static object TestingSetup { get; private set; } public TestingSetup TestingSetup { get; private set; }
public IEmailSender MailSender public IEmailSender MailSender
{ {
@ -76,9 +76,9 @@ namespace test
internal void UpgradeDb() internal int UpgradeDb()
{ {
Microsoft.Data.Entity.Commands.Program.Main( return Microsoft.Data.Entity.Commands.Program.Main(
new string[] { "database", "update" }); new string[] { "database", "update" });
} }
@ -95,7 +95,7 @@ namespace test
} }
} }
bool dbCreated; bool dbCreated;
private readonly WebHostBuilder host; public WebHostBuilder Host { get; private set; }
private readonly IHostingEngine hostengnine; private readonly IHostingEngine hostengnine;
@ -108,13 +108,13 @@ namespace test
// //
public ServerSideFixture() public ServerSideFixture()
{ {
host = new WebHostBuilder(); Host = new WebHostBuilder();
AssertNotNull(host, nameof(host)); AssertNotNull(Host, nameof(Host));
hostengnine = host hostengnine = Host
.UseEnvironment("Development") .UseEnvironment("Testing")
.UseServer("test") .UseServer("yavscTests")
.UseStartup<test.Startup>() .UseStartup<Startup>()
.Build(); .Build();
AssertNotNull(hostengnine, nameof(hostengnine)); AssertNotNull(hostengnine, nameof(hostengnine));
@ -132,20 +132,27 @@ namespace test
_loggerFactory = App.Services.GetService(typeof(ILoggerFactory)) as ILoggerFactory; _loggerFactory = App.Services.GetService(typeof(ILoggerFactory)) as ILoggerFactory;
AssertNotNull(_loggerFactory, nameof(_loggerFactory)); AssertNotNull(_loggerFactory, nameof(_loggerFactory));
var siteSetup = App.Services.GetService(typeof(IOptions<SiteSettings>)) as IOptions<SiteSettings>; var siteSetup = App.Services.GetService(typeof(IOptions<SiteSettings>)) as IOptions<SiteSettings>;
AssertNotNull(siteSetup, nameof(siteSetup)); AssertNotNull(siteSetup, nameof(siteSetup));
var testingSetup = App.Services.GetService(typeof(IOptions<Testing>)) as IOptions<Testing>;
var testingSetup = App.Services.GetService(typeof(IOptions<TestingSetup>)) as IOptions<TestingSetup>;
AssertNotNull(testingSetup, nameof(testingSetup));
DbContext = App.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; DbContext = App.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;
SiteSetup = siteSetup.Value; SiteSetup = siteSetup.Value;
TestingSetup = testingSetup.Value; AssertNotNull(SiteSetup, nameof(SiteSetup));
TestingSetup = testingSetup.Value;
AssertNotNull(TestingSetup, nameof(TestingSetup));
Logger = _loggerFactory.CreateLogger<ServerSideFixture>(); Logger = _loggerFactory.CreateLogger<ServerSideFixture>();
AssertNotNull(Logger, nameof(Logger));
var builder = new DbConnectionStringBuilder var builder = new DbConnectionStringBuilder
{ {
ConnectionString = Startup.Testing.ConnectionStrings.Default ConnectionString = Startup.TestingSetup.ConnectionStrings.Default
}; };
ConventionSet conventions = new ConventionSet(); ConventionSet conventions = new ConventionSet();
@ -155,6 +162,7 @@ namespace test
TestingDatabase = (string)builder["Database"]; TestingDatabase = (string)builder["Database"];
AssertNotNull(TestingDatabase, nameof(TestingDatabase));
Logger.LogInformation("ServerSideFixture created."); Logger.LogInformation("ServerSideFixture created.");
} }
@ -167,7 +175,7 @@ namespace test
public void CheckDbExistence() public void CheckDbExistence()
{ {
using ( using (
NpgsqlConnection cx = new NpgsqlConnection(Startup.Testing.ConnectionStrings.DatabaseCtor)) NpgsqlConnection cx = new NpgsqlConnection(Startup.TestingSetup.ConnectionStrings.Default))
{ {
cx.Open(); cx.Open();
_logger.LogInformation($"check db for TestingDatabase:{TestingDatabase}"); _logger.LogInformation($"check db for TestingDatabase:{TestingDatabase}");
@ -183,16 +191,19 @@ namespace test
{ {
if (!DbCreated) if (!DbCreated)
{ {
using (NpgsqlConnection cx = new NpgsqlConnection(Startup.Testing.ConnectionStrings.DatabaseCtor)) using (NpgsqlConnection cx =
new NpgsqlConnection(Startup.TestingSetup.ConnectionStrings.DatabaseCtor))
{ {
_logger.LogInformation($"create database for TestingDatabase : {TestingDatabase}"); _logger.LogInformation($"create database for TestingDatabase : {TestingDatabase}");
cx.Open(); cx.Open();
var command = cx.CreateCommand(); var command = cx.CreateCommand();
using (NpgsqlConnection ownercx = new NpgsqlConnection(Startup.Testing.ConnectionStrings.Default)) using (NpgsqlConnection ownercx = new NpgsqlConnection(Startup.TestingSetup.ConnectionStrings.Default))
command.CommandText = $"create database \"{TestingDatabase}\" OWNER \"{ownercx.UserName}\";"; command.CommandText = $"create database \"{TestingDatabase}\" OWNER \"{ownercx.UserName}\";";
_logger.LogInformation(command.CommandText); _logger.LogInformation(command.CommandText);
command.ExecuteNonQuery(); command.ExecuteNonQuery();
cx.Close();
} }
dbCreated = true; dbCreated = true;
@ -213,7 +224,15 @@ namespace test
} }
public bool DbCreated { get { public bool DbCreated { get {
try {
CheckDbExistence(); CheckDbExistence();
}
catch (Exception ex)
{
_logger.LogError(ex.Message);
_logger.LogError(ex.StackTrace);
}
return dbCreated; } } return dbCreated; } }
} }
} }

@ -3,7 +3,7 @@ using Xunit;
using Xunit.Abstractions; using Xunit.Abstractions;
using Yavsc.Helpers; using Yavsc.Helpers;
namespace test namespace yavscTests
{ {
[Collection("Yavsc Abstract tests")] [Collection("Yavsc Abstract tests")]
[Trait("regression", "II")] [Trait("regression", "II")]

@ -2,7 +2,7 @@ using System;
using Xunit; using Xunit;
using Xunit.Abstractions; using Xunit.Abstractions;
namespace test.Mandatory namespace yavscTests.Mandatory
{ {
[Collection("Database")] [Collection("Database")]
[Trait("regression", "II")] [Trait("regression", "II")]
@ -25,7 +25,7 @@ namespace test.Mandatory
{ {
output.WriteLine("db not dropped"); output.WriteLine("db not dropped");
} }
output.WriteLine($"Startup.Testing.ConnectionStrings.DatabaseCtor is {Startup.Testing.ConnectionStrings.DatabaseCtor}"); output.WriteLine($"Startup.Testing.ConnectionStrings.Default is {Startup.TestingSetup.ConnectionStrings.Default}");
} }
/// <summary> /// <summary>
@ -35,8 +35,8 @@ namespace test.Mandatory
[Fact] [Fact]
public void InstallFromScratchUsingPoweredNpgsqlUser() public void InstallFromScratchUsingPoweredNpgsqlUser()
{ {
_serverFixture.EnsureTestDb(); Assert.True(_serverFixture.EnsureTestDb());
_serverFixture.UpgradeDb(); Assert.True(_serverFixture.UpgradeDb()==0);
} }
public void Dispose() public void Dispose()

@ -3,7 +3,7 @@ using Xunit;
using Xunit.Abstractions; using Xunit.Abstractions;
using Yavsc.Abstract.Manage; using Yavsc.Abstract.Manage;
namespace test namespace yavscTests
{ {
[Collection("EMaillingTeststCollection")] [Collection("EMaillingTeststCollection")]

@ -3,7 +3,7 @@ using Xunit;
using System.IO; using System.IO;
using System.Diagnostics; using System.Diagnostics;
namespace test namespace yavscTests
{ {
/// <summary> /// <summary>

@ -1,4 +1,4 @@
namespace test.Settings namespace yavscTests.Settings
{ {
public class DbConnectionSettings public class DbConnectionSettings
{ {

@ -1,22 +1,23 @@
namespace test.Settings namespace yavscTests.Settings
{ {
public class PasswordCreds public class PasswordCreds
{ {
public string UserName { get; set; } public string UserName { get; set; }
public string Password { get; set; } public string Password { get; set; }
} }
public class Testing public class TestingSetup
{ {
public DbConnectionSettings ConnectionStrings { get; set; } public DbConnectionSettings ConnectionStrings { get; set; }
public PasswordCreds[] ValidCreds public PasswordCreds ValidCreds
{ {
get; set; get; set;
} }
public PasswordCreds[] InvalidCreds public PasswordCreds InvalidCreds
{ {
get; set; get; set;
} }
public string YavscWebPath {get; set; }
} }
} }

@ -12,7 +12,7 @@ using Yavsc.Models;
using Yavsc.Services; using Yavsc.Services;
using Microsoft.Data.Entity; using Microsoft.Data.Entity;
using Microsoft.Extensions.WebEncoders; using Microsoft.Extensions.WebEncoders;
using test.Settings; using yavscTests.Settings;
using Microsoft.AspNet.Diagnostics; using Microsoft.AspNet.Diagnostics;
using System.Net; using System.Net;
using Yavsc.Extensions; using Yavsc.Extensions;
@ -49,7 +49,7 @@ using Microsoft.AspNet.Identity.EntityFramework;
using Yavsc.Auth; using Yavsc.Auth;
using Yavsc.Lib; using Yavsc.Lib;
namespace test namespace yavscTests
{ {
public class Startup public class Startup
{ {
@ -60,7 +60,7 @@ namespace test
public ApplicationDbContext DbContext { get; private set; } public ApplicationDbContext DbContext { get; private set; }
public static Testing Testing { get; private set; } public static TestingSetup TestingSetup { get; private set; }
public static IConfigurationRoot GoogleWebClientConfiguration { get; set; } public static IConfigurationRoot GoogleWebClientConfiguration { get; set; }
@ -70,6 +70,8 @@ namespace test
public Yavsc.Auth.YavscGoogleOptions YavscGoogleAppOptions { get; private set; } public Yavsc.Auth.YavscGoogleOptions YavscGoogleAppOptions { get; private set; }
private static ILogger logger; private static ILogger logger;
public static string ApiKey { get; private set; }
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv) public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
{ {
@ -108,7 +110,7 @@ namespace test
var dbSettingsconf = Configuration.GetSection("ConnectionStrings"); var dbSettingsconf = Configuration.GetSection("ConnectionStrings");
services.Configure<DbConnectionSettings>(dbSettingsconf); services.Configure<DbConnectionSettings>(dbSettingsconf);
var testingconf = Configuration.GetSection("Testing"); var testingconf = Configuration.GetSection("Testing");
services.Configure<Testing>(testingconf); services.Configure<TestingSetup>(testingconf);
services.AddInstance(typeof(ILoggerFactory), new LoggerFactory()); services.AddInstance(typeof(ILoggerFactory), new LoggerFactory());
services.AddTransient(typeof(IEmailSender), typeof(MailSender)); services.AddTransient(typeof(IEmailSender), typeof(MailSender));
@ -408,7 +410,7 @@ namespace test
IApplicationBuilder app, IApplicationBuilder app,
IHostingEnvironment env, IHostingEnvironment env,
ApplicationDbContext dbContext, ApplicationDbContext dbContext,
IOptions<Testing> testingSettings, IOptions<TestingSetup> testingSettings,
UserManager<ApplicationUser> usermanager, UserManager<ApplicationUser> usermanager,
ILoggerFactory loggerFactory ILoggerFactory loggerFactory
) )
@ -418,17 +420,15 @@ namespace test
logger = loggerFactory.CreateLogger<Startup>(); logger = loggerFactory.CreateLogger<Startup>();
logger.LogInformation(env.EnvironmentName); logger.LogInformation(env.EnvironmentName);
this.DbContext = dbContext; this.DbContext = dbContext;
Testing = testingSettings.Value; TestingSetup = testingSettings.Value;
_usermanager = usermanager; _usermanager = usermanager;
#if USERMANAGER
#endif
if (Testing.ConnectionStrings == null) if (TestingSetup.ConnectionStrings == null)
logger.LogInformation($" Testing.ConnectionStrings is null : "); logger.LogInformation($" Testing.ConnectionStrings is null : ");
else else
{ {
AppDomain.CurrentDomain.SetData("YAVSC_DB_CONNECTION", Testing.ConnectionStrings.Default); AppDomain.CurrentDomain.SetData("YAVSC_DB_CONNECTION", TestingSetup.ConnectionStrings.Default);
} }
var authConf = Configuration.GetSection("Authentication").GetSection("Yavsc"); var authConf = Configuration.GetSection("Authentication").GetSection("Yavsc");

@ -1,7 +1,7 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace test { namespace yavscTests {
public static class AssertAsync { public static class AssertAsync {

@ -11,7 +11,7 @@ using Microsoft.AspNet.Hosting;
using Microsoft.Dnx.TestHost.TestAdapter; using Microsoft.Dnx.TestHost.TestAdapter;
using Xunit.Abstractions; using Xunit.Abstractions;
namespace test namespace yavscTests
{ {
[Collection("Yavsc dropped intents")] [Collection("Yavsc dropped intents")]
[Trait("regres", "yes")] [Trait("regres", "yes")]

@ -31,36 +31,37 @@
"EnableSSL": false "EnableSSL": false
}, },
"Logging": { "Logging": {
"IncludeScopes": true, "IncludeScopes": {
},
"LogLevel": { "LogLevel": {
"Default": "Debug", "Default": "Debug",
"System": "Warning", "System": "Warning",
"Microsoft": "Warning" "Microsoft": "Warning"
} }
}, },
"Testing": { "ConnectionStrings": {
"ConnectionStrings": { "Default": "Server=lame-NpgsqlHostName;Port=5432;Database=lame-DataBase;Username=lame-Username;Password=lame-dbPassword;",
"Default": "Server=lame-NpgsqlHostName;Port=5432;Database=lame-DataBase;Username=lame-Username;Password=lame-dbPassword;", "DatabaseCtor": "Server=lame-NpgsqlHostName;Port=5432;Database=lame-ctor-DataBase;Username=lame-ctor-Username;Password=lame-ctordbPassword;"
"DatabaseCtor": "Server=lame-NpgsqlHostName;Port=5432;Database=lame-ctor-DataBase;Username=lame-ctor-Username;Password=lame-ctordbPassword;"
},
"ValidCreds": [
{
"UserName": "lame-user",
"Password": "lame-password"
}
],
"InvalidCreds": [
{
"UserName": "lame-fakeuser",
"Password": "lame-fakepassword"
}
]
}, },
"ValidCreds": {
"UserName": "lame-user",
"Password": "lame-password"
},
"InvalidCreds": {
"UserName": "fakeuser",
"Password": "f/\\kePassw0rd"
},
"YavscWebPath": "../../src/Yavsc",
"DataProtection": { "DataProtection": {
"Keys": { "Keys": {
"Dir": "DataProtection-Keys" "Dir": "DataProtection-Keys"
}, },
"RSAParamFile": "ls ", "RSAParamFile": "RSAParamFile",
"ExpiresInHours": 168 "ExpiresInHours": 168
},
"ApiKey": "lame-key",
"Testing": {
"ConnectionStrings": {"Default": "none"}
} }
} }

Loading…