You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lidarr/NzbDrone.Core.Test/Framework/TestDbHelper.cs

52 lines
1.6 KiB

// ReSharper disable RedundantUsingDirective
using System;
using System.Collections.Generic;
using System.IO;
14 years ago
using FizzWare.NBuilder;
using Moq;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Providers.Core;
14 years ago
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
14 years ago
using PetaPoco;
namespace NzbDrone.Core.Test.Framework
{
internal static class TestDbHelper
{
private const string DB_TEMPLATE_NAME = "_dbtemplate.sdf";
internal static string ConnectionString { get; private set; }
internal static IDatabase GetEmptyDatabase(bool enableLogging = false, string fileName = "")
14 years ago
{
Console.WriteLine("====================DataBase====================");
Console.WriteLine("Cloning database from template.");
14 years ago
if (String.IsNullOrWhiteSpace(fileName))
{
fileName = Guid.NewGuid() + ".sdf";
14 years ago
}
File.Copy(DB_TEMPLATE_NAME, fileName);
ConnectionString = Connection.GetConnectionString(fileName);
var database = Connection.GetPetaPocoDb(ConnectionString);
14 years ago
Console.WriteLine("====================DataBase====================");
Console.WriteLine();
Console.WriteLine();
14 years ago
return database;
}
internal static void CreateDataBaseTemplate()
{
Console.WriteLine("Creating an empty PetaPoco database");
var connectionString = Connection.GetConnectionString(DB_TEMPLATE_NAME);
var database = Connection.GetPetaPocoDb(connectionString);
database.Dispose();
}
}
}