mirror of
https://github.com/lidarr/Lidarr
synced 2024-12-29 02:55:38 +00:00
64 lines
1.5 KiB
C#
64 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Migrator.Providers.SqlServer;
|
|
using NzbDrone.Services.Service.Migrations;
|
|
using NzbDrone.Test.Common;
|
|
using NzbDrone.Test.Common.AutoMoq;
|
|
using Services.PetaPoco;
|
|
|
|
|
|
namespace NzbDrone.Services.Tests.Framework
|
|
{
|
|
public abstract class ServicesTestBase : LoggingTest
|
|
{
|
|
static readonly string connectionString = ConfigurationManager.ConnectionStrings["SqlExpress"].ConnectionString;
|
|
|
|
static ServicesTestBase()
|
|
{
|
|
|
|
}
|
|
|
|
private static void ResetDb()
|
|
{
|
|
var transformationProvider = new SqlServerTransformationProvider(new SqlServerDialect(), connectionString);
|
|
|
|
var tables = transformationProvider.GetTables();
|
|
|
|
foreach (var table in tables)
|
|
{
|
|
transformationProvider.RemoveTable(table);
|
|
}
|
|
|
|
|
|
MigrationsHelper.Run(connectionString);
|
|
}
|
|
|
|
public IDatabase Db { get; private set; }
|
|
|
|
private AutoMoqer _mocker;
|
|
protected AutoMoqer Mocker
|
|
{
|
|
get
|
|
{
|
|
if (_mocker == null)
|
|
{
|
|
_mocker = new AutoMoqer();
|
|
}
|
|
|
|
return _mocker;
|
|
}
|
|
}
|
|
|
|
protected void WithRealDb()
|
|
{
|
|
ResetDb();
|
|
|
|
Db = new Database("SqlExpress");
|
|
Mocker.SetConstant(Db);
|
|
}
|
|
|
|
}
|
|
}
|