mirror of
https://github.com/Radarr/Radarr
synced 2024-12-23 00:12:44 +00:00
TestDbHelper cleanup
This commit is contained in:
parent
1b45a85f3f
commit
ed566e6e9a
2 changed files with 25 additions and 28 deletions
|
@ -16,9 +16,9 @@ internal static class TestDbHelper
|
|||
{
|
||||
private const string DB_TEMPLATE_NAME = "_dbtemplate.sdf";
|
||||
|
||||
public static string ConnectionString { get; private set; }
|
||||
internal static string ConnectionString { get; private set; }
|
||||
|
||||
public static IDatabase GetEmptyDatabase(bool enableLogging = false, string fileName = "")
|
||||
internal static IDatabase GetEmptyDatabase(bool enableLogging = false, string fileName = "")
|
||||
{
|
||||
Console.WriteLine("====================DataBase====================");
|
||||
Console.WriteLine("Cloning database from template.");
|
||||
|
@ -41,21 +41,12 @@ public static IDatabase GetEmptyDatabase(bool enableLogging = false, string file
|
|||
return database;
|
||||
}
|
||||
|
||||
public static void CreateDataBaseTemplate()
|
||||
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();
|
||||
}
|
||||
|
||||
public static Series GetFakeSeries(int id, string title)
|
||||
{
|
||||
return Builder<Series>.CreateNew()
|
||||
.With(c => c.SeriesId = id)
|
||||
.With(c => c.Title = title)
|
||||
.With(c => c.CleanTitle = Parser.NormalizeTitle(title))
|
||||
.Build();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,14 +3,12 @@
|
|||
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
namespace NzbDrone.Core.Test.ProviderTests
|
||||
|
@ -134,14 +132,16 @@ public void find_series_empty_match()
|
|||
{
|
||||
WithRealDb();
|
||||
|
||||
Db.Insert(TestDbHelper.GetFakeSeries(1, "MyTitle"));
|
||||
var fakeSEries = Builder<Series>.CreateNew()
|
||||
.Build();
|
||||
|
||||
Db.Insert(fakeSEries);
|
||||
|
||||
//Act
|
||||
var seriesProvider = Mocker.Resolve<SeriesProvider>();
|
||||
var series = seriesProvider.FindSeries("WrongTitle");
|
||||
|
||||
|
||||
//Assert
|
||||
Assert.IsNull(series);
|
||||
seriesProvider.FindSeries("WrongTitle").Should().BeNull();
|
||||
}
|
||||
|
||||
[TestCase("The Test", "Test")]
|
||||
|
@ -150,19 +150,25 @@ public void find_series_match(string title, string searchTitle)
|
|||
{
|
||||
WithRealDb();
|
||||
|
||||
Db.Insert(TestDbHelper.GetFakeSeries(1, title));
|
||||
Db.Insert(Builder<QualityProfile>.CreateNew().Build());
|
||||
Mocker.Resolve<QualityProvider>();
|
||||
var fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.Title = title)
|
||||
.With(c => c.CleanTitle = Parser.NormalizeTitle(title))
|
||||
.Build();
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew()
|
||||
.With(c => c.QualityProfileId = fakeSeries.QualityProfileId)
|
||||
.Build();
|
||||
|
||||
Db.Insert(fakeSeries);
|
||||
Db.Insert(fakeQuality);
|
||||
|
||||
//Act
|
||||
var seriesProvider = Mocker.Resolve<SeriesProvider>();
|
||||
var series = seriesProvider.FindSeries(searchTitle);
|
||||
var series = Mocker.Resolve<SeriesProvider>().FindSeries(searchTitle);
|
||||
|
||||
//Assert
|
||||
Assert.IsNotNull(series);
|
||||
Assert.AreEqual(title, series.Title);
|
||||
series.QualityProfile.Should().NotBeNull();
|
||||
series.QualityProfile.ShouldHave().Properties(q => q.Name, q => q.SonicAllowed, q => q.Cutoff, q => q.AllowedString);
|
||||
series.Should().NotBeNull();
|
||||
series.SeriesId.Should().Be(series.SeriesId);
|
||||
series.Title.Should().BeEquivalentTo(series.Title);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -651,7 +657,7 @@ public void SearchForSeries_should_return_results_that_end_with_the_query()
|
|||
[Test]
|
||||
public void SearchForSeries_should_not_return_results_that_do_not_contain_the_query()
|
||||
{
|
||||
WithRealDb();
|
||||
WithRealDb();
|
||||
|
||||
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
|
||||
var fakeSeries = Builder<Series>.CreateListOfSize(10)
|
||||
|
|
Loading…
Reference in a new issue