btcpayserver/BTCPayServer.Tests/UnitTestBase.cs

40 lines
1.3 KiB
C#
Raw Normal View History

2021-11-22 16:49:51 +01:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using BTCPayServer.Tests.Logging;
using Xunit.Abstractions;
namespace BTCPayServer.Tests
{
public class UnitTestBase
{
public UnitTestBase(ITestOutputHelper helper)
{
TestLogs = new XUnitLog(helper) { Name = "Tests" };
TestLogProvider = new XUnitLogProvider(helper);
2021-11-22 09:16:08 +01:00
BTCPayLogs = new BTCPayServer.Logging.Logs();
BTCPayLogs.Configure(new BTCPayServer.Logging.FuncLoggerFactory((n) => new XUnitLog(helper) { Name = n }));
2021-11-22 16:49:51 +01:00
}
public ILog TestLogs
{
get;
}
public XUnitLogProvider TestLogProvider
{
get;
}
2021-11-22 09:16:08 +01:00
public BTCPayServer.Logging.Logs BTCPayLogs { get; }
2021-11-22 16:49:51 +01:00
public ServerTester CreateServerTester([CallerMemberNameAttribute] string scope = null, bool newDb = false)
{
2021-11-22 09:16:08 +01:00
return new ServerTester(scope, newDb, TestLogs, TestLogProvider);
2021-11-22 16:49:51 +01:00
}
public SeleniumTester CreateSeleniumTester([CallerMemberNameAttribute] string scope = null, bool newDb = false)
{
2021-11-22 09:16:08 +01:00
return new SeleniumTester() { Server = new ServerTester(scope, newDb, TestLogs, TestLogProvider) };
2021-11-22 16:49:51 +01:00
}
}
}