2018-03-28 22:08:49 +00:00
|
|
|
|
using BotSharp.Core.Engines;
|
2017-12-30 20:26:35 +00:00
|
|
|
|
using EntityFrameworkCore.BootKit;
|
|
|
|
|
|
using Microsoft.Data.Sqlite;
|
2018-03-19 02:07:36 +00:00
|
|
|
|
using Microsoft.Extensions.Configuration;
|
2017-12-30 20:26:35 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.IO;
|
2018-03-19 02:07:36 +00:00
|
|
|
|
using System.Linq;
|
2017-12-30 20:26:35 +00:00
|
|
|
|
|
2018-03-28 22:08:49 +00:00
|
|
|
|
namespace BotSharp.UnitTest
|
2017-12-30 20:26:35 +00:00
|
|
|
|
{
|
|
|
|
|
|
public abstract class TestEssential
|
|
|
|
|
|
{
|
2018-06-18 14:15:54 +00:00
|
|
|
|
public static String BOT_ID = "6a9fd374-c43d-447a-97f2-f37540d0c725";
|
2018-03-28 22:08:49 +00:00
|
|
|
|
|
2017-12-30 20:26:35 +00:00
|
|
|
|
protected Database dc { get; set; }
|
2018-03-19 02:07:36 +00:00
|
|
|
|
protected string contentRoot;
|
2017-12-30 20:26:35 +00:00
|
|
|
|
|
|
|
|
|
|
public TestEssential()
|
|
|
|
|
|
{
|
2018-07-18 16:18:34 +00:00
|
|
|
|
contentRoot = $"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}..{Path.DirectorySeparatorChar}..{Path.DirectorySeparatorChar}..{Path.DirectorySeparatorChar}..{Path.DirectorySeparatorChar}BotSharp.WebHost{Path.DirectorySeparatorChar}";
|
2018-03-19 02:07:36 +00:00
|
|
|
|
|
|
|
|
|
|
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
|
2018-07-18 16:18:34 +00:00
|
|
|
|
var settings = Directory.GetFiles(contentRoot + $"Settings{Path.DirectorySeparatorChar}", "*.json");
|
2018-03-19 02:07:36 +00:00
|
|
|
|
settings.ToList().ForEach(setting =>
|
|
|
|
|
|
{
|
|
|
|
|
|
configurationBuilder.AddJsonFile(setting, optional: false, reloadOnChange: true);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2018-08-02 21:14:46 +00:00
|
|
|
|
AppDomain.CurrentDomain.SetData("DataPath", Path.Join(contentRoot, "App_Data"));
|
|
|
|
|
|
AppDomain.CurrentDomain.SetData("Configuration", configurationBuilder.Build());
|
|
|
|
|
|
AppDomain.CurrentDomain.SetData("ContentRootPath", contentRoot);
|
|
|
|
|
|
AppDomain.CurrentDomain.SetData("Assemblies", new String[] { "BotSharp.Core" });
|
2018-03-19 02:07:36 +00:00
|
|
|
|
|
|
|
|
|
|
dc = new DefaultDataContextLoader().GetDefaultDc();
|
2017-12-30 20:26:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|