BotSharp/BotSharp.Core.UnitTest/TestEssential.cs

40 lines
1.6 KiB
C#
Raw Normal View History

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-08-19 03:42:51 +00:00
namespace BotSharp.Core.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-09-13 12:37:26 +00:00
contentRoot = Path.GetFullPath(contentRoot);
2018-03-19 02:07:36 +00:00
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
2018-09-27 01:55:21 +00:00
var settings = Directory.GetFiles(Path.Combine(contentRoot, "Settings"), "*.json");
2018-03-19 02:07:36 +00:00
settings.ToList().ForEach(setting =>
{
configurationBuilder.AddJsonFile(setting, optional: false, reloadOnChange: true);
});
AppDomain.CurrentDomain.SetData("DataPath", Path.Combine(contentRoot, "App_Data"));
2018-08-02 21:14:46 +00:00
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
}
}
}