mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-26 22:46:37 -04:00
Removed subsonic completely
This commit is contained in:
@@ -37,32 +37,6 @@ namespace NzbDrone.Core.Test.Framework
|
||||
}
|
||||
|
||||
|
||||
public static IRepository GetEmptyRepository(bool enableLogging = false, string fileName = "")
|
||||
{
|
||||
Console.WriteLine("Creating an empty Subsonic repository");
|
||||
|
||||
if (String.IsNullOrWhiteSpace(fileName))
|
||||
{
|
||||
fileName = Guid.NewGuid() + ".db";
|
||||
}
|
||||
|
||||
|
||||
var provider = Connection.GetDataProvider(Connection.GetConnectionString(fileName));
|
||||
var repo = Connection.CreateSimpleRepository(provider);
|
||||
ForceMigration(repo);
|
||||
|
||||
//Migrations.Run(Connection.GetConnectionString(fileName), false);
|
||||
|
||||
if (enableLogging)
|
||||
{
|
||||
provider.Log = new NlogWriter();
|
||||
}
|
||||
Console.WriteLine("**********************************************************************************");
|
||||
Console.WriteLine("*****************************REPO IS READY****************************************");
|
||||
Console.WriteLine("**********************************************************************************");
|
||||
return repo;
|
||||
}
|
||||
|
||||
public static IDatabase GetEmptyDatabase(bool enableLogging = false, string fileName = "")
|
||||
{
|
||||
Console.WriteLine("Creating an empty PetaPoco database");
|
||||
@@ -71,9 +45,9 @@ namespace NzbDrone.Core.Test.Framework
|
||||
{
|
||||
fileName = Guid.NewGuid() + ".db";
|
||||
}
|
||||
|
||||
|
||||
var connectionString = Connection.GetConnectionString(fileName);
|
||||
|
||||
|
||||
var database = Connection.GetPetaPocoDb(connectionString);
|
||||
|
||||
return database;
|
||||
|
||||
@@ -116,7 +116,6 @@
|
||||
<Compile Include="Framework\ExceptionVerification.cs" />
|
||||
<Compile Include="JobProviderTest.cs" />
|
||||
<Compile Include="QualityTest.cs" />
|
||||
<Compile Include="RepositoryProviderTest.cs" />
|
||||
<Compile Include="RootDirProviderTest.cs" />
|
||||
<Compile Include="IndexerProviderTest.cs" />
|
||||
<Compile Include="HistoryProviderTest.cs" />
|
||||
@@ -128,7 +127,6 @@
|
||||
<Compile Include="ParserTest.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="QualityProfileTest.cs" />
|
||||
<Compile Include="RepoTest.cs" />
|
||||
<Compile Include="SabProviderTest.cs" />
|
||||
<Compile Include="SceneMappingTest.cs" />
|
||||
<Compile Include="SeriesProviderTest.cs" />
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
// ReSharper disable RedundantUsingDirective
|
||||
using System;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NLog;
|
||||
using NLog.Config;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Instrumentation;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using LogLevel = NLog.LogLevel;
|
||||
|
||||
namespace NzbDrone.Core.Test
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class RepoTest : TestBase
|
||||
{
|
||||
[Test]
|
||||
public void to_many__series_to_episode()
|
||||
{
|
||||
//Arrange
|
||||
var fakeSeries = Builder<Series>.CreateNew().With(s => s.SeriesId = 69).Build();
|
||||
var fakeEpisode = Builder<Episode>.CreateNew().With(c => c.SeriesId = 69).Build();
|
||||
|
||||
//Act
|
||||
var repo = MockLib.GetEmptyRepository(true);
|
||||
repo.Add(fakeSeries);
|
||||
repo.Add(fakeEpisode);
|
||||
var fetchedSeries = repo.Single<Series>(fakeSeries.SeriesId);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(fakeSeries.SeriesId, fetchedSeries.SeriesId);
|
||||
Assert.AreEqual(fakeSeries.Title, fetchedSeries.Title);
|
||||
|
||||
|
||||
fetchedSeries.Episodes.Should().HaveCount(1);
|
||||
Assert.AreEqual(fetchedSeries.Episodes[0].EpisodeId, fakeEpisode.EpisodeId);
|
||||
Assert.AreEqual(fetchedSeries.Episodes[0].SeriesId, fakeEpisode.SeriesId);
|
||||
Assert.AreEqual(fetchedSeries.Episodes[0].Title, fakeEpisode.Title);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void query_scratch_pad()
|
||||
{
|
||||
|
||||
var repo = MockLib.GetEmptyRepository(true);
|
||||
|
||||
repo.All<Episode>().Where(e => !e.Ignored && e.AirDate <= DateTime.Today && e.AirDate.Year > 1900).Select(
|
||||
s => s.Title).ToList();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
[Ignore]
|
||||
public void episode_proxy_to_string()
|
||||
{
|
||||
var episode = Builder<Episode>.CreateNew()
|
||||
.Build();
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.With(s => s.SeriesId = episode.SeriesId)
|
||||
.Build();
|
||||
|
||||
var repo = MockLib.GetEmptyRepository(true);
|
||||
repo.Add(episode);
|
||||
repo.Add(series);
|
||||
|
||||
//Act
|
||||
|
||||
var result = repo.Single<Episode>(episode.EpisodeId).ToString();
|
||||
|
||||
//Assert
|
||||
Console.WriteLine(result);
|
||||
result.Should().Contain(series.Title);
|
||||
result.Should().Contain(episode.EpisodeNumber.ToString());
|
||||
result.Should().Contain(episode.SeasonNumber.ToString());
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
[Description(
|
||||
"This test confirms that the tvdb id stored in the db is preserved rather than being replaced by an auto incrementing value"
|
||||
)]
|
||||
public void tvdbid_is_preserved()
|
||||
{
|
||||
//Arrange
|
||||
var sonicRepo = MockLib.GetEmptyRepository(true);
|
||||
var series = Builder<Series>.CreateNew().With(c => c.SeriesId = 18).Build();
|
||||
|
||||
//Act
|
||||
var addId = sonicRepo.Add(series);
|
||||
|
||||
//Assert
|
||||
Assert.AreEqual(18, addId);
|
||||
var allSeries = sonicRepo.All<Series>();
|
||||
allSeries.Should().HaveCount(1);
|
||||
Assert.AreEqual(18, allSeries.First().SeriesId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void enteties_toString()
|
||||
{
|
||||
Console.WriteLine(new Episode().ToString());
|
||||
Console.WriteLine(new Series().ToString());
|
||||
Console.WriteLine(new EpisodeFile().ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,175 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using FluentAssertions;
|
||||
using Migrator.Framework;
|
||||
using Migrator.Providers.SQLite;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Instrumentation;
|
||||
using NzbDrone.Core.Repository;
|
||||
using NzbDrone.Core.Repository.Quality;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using SubSonic.DataProviders;
|
||||
using SubSonic.Repository;
|
||||
using SubSonic.Schema;
|
||||
using SubSonic.SqlGeneration.Schema;
|
||||
|
||||
namespace NzbDrone.Core.Test
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class RepositoryProviderTest : TestBase
|
||||
{
|
||||
[Test]
|
||||
public void Get_Assembly_repos()
|
||||
{
|
||||
var provider = new RepositoryProvider();
|
||||
var types = provider.GetRepositoryTypes();
|
||||
|
||||
types.Should().Contain(typeof(Config));
|
||||
types.Should().Contain(typeof(Episode));
|
||||
types.Should().Contain(typeof(EpisodeFile));
|
||||
types.Should().Contain(typeof(ExternalNotificationSetting));
|
||||
types.Should().Contain(typeof(History));
|
||||
types.Should().Contain(typeof(IndexerSetting));
|
||||
types.Should().Contain(typeof(JobSetting));
|
||||
types.Should().Contain(typeof(RootDir));
|
||||
types.Should().Contain(typeof(Series));
|
||||
types.Should().Contain(typeof(QualityProfile));
|
||||
|
||||
types.Should().NotContain(typeof(QualityTypes));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[Test]
|
||||
public void Get_table_columns()
|
||||
{
|
||||
var provider = new RepositoryProvider();
|
||||
var typeTable = provider.GetSchemaFromType(typeof(TestRepoType));
|
||||
|
||||
Assert.IsNotNull(typeTable.Columns);
|
||||
|
||||
typeTable.Columns.Should().HaveCount(3);
|
||||
Assert.AreEqual("TestRepoTypes", typeTable.Name);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertToMigratorColumn()
|
||||
{
|
||||
var provider = new RepositoryProvider();
|
||||
|
||||
var subsonicColumn = new DatabaseColumn
|
||||
{
|
||||
Name = "Name",
|
||||
DataType = DbType.Boolean,
|
||||
IsPrimaryKey = true,
|
||||
IsNullable = true
|
||||
};
|
||||
|
||||
var migColumn = provider.ConvertToMigratorColumn(subsonicColumn);
|
||||
|
||||
Assert.IsTrue(migColumn.IsPrimaryKey);
|
||||
Assert.AreEqual(ColumnProperty.Null | ColumnProperty.PrimaryKey, migColumn.ColumnProperty);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void GetDbColumns()
|
||||
{
|
||||
string connectionString = "Data Source=" + Guid.NewGuid() + ".db;Version=3;New=True";
|
||||
var dbProvider = ProviderFactory.GetProvider(connectionString, "System.Data.SQLite");
|
||||
var repo = new SimpleRepository(dbProvider, SimpleRepositoryOptions.RunMigrations);
|
||||
var sqliteDatabase = new SQLiteTransformationProvider(new SQLiteDialect(), connectionString);
|
||||
|
||||
repo.Add(new TestRepoType() { Value = "Dummy" });
|
||||
|
||||
var repositoryProvider = new RepositoryProvider();
|
||||
var columns = repositoryProvider.GetColumnsFromDatabase(sqliteDatabase, "TestRepoTypes");
|
||||
|
||||
columns.Should().HaveCount(3);
|
||||
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void DeleteColumns()
|
||||
{
|
||||
string connectionString = "Data Source=" + Guid.NewGuid() + ".db;Version=3;New=True";
|
||||
var dbProvider = ProviderFactory.GetProvider(connectionString, "System.Data.SQLite");
|
||||
var sqliteDatabase = new SQLiteTransformationProvider(new SQLiteDialect(), connectionString);
|
||||
var repo = new SimpleRepository(dbProvider, SimpleRepositoryOptions.RunMigrations);
|
||||
|
||||
repo.Add(new TestRepoType() { Value = "Dummy" });
|
||||
|
||||
var repositoryProvider = new RepositoryProvider();
|
||||
var typeSchema = repositoryProvider.GetSchemaFromType(typeof(TestRepoType2));
|
||||
var columns = repositoryProvider.GetColumnsFromDatabase(sqliteDatabase, "TestRepoTypes");
|
||||
|
||||
|
||||
var deletedColumns = repositoryProvider.GetDeletedColumns(typeSchema, columns);
|
||||
|
||||
|
||||
deletedColumns.Should().HaveCount(1);
|
||||
Assert.AreEqual("NewName", deletedColumns[0].Name.Trim('[', ']'));
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void NewColumns()
|
||||
{
|
||||
string connectionString = "Data Source=" + Guid.NewGuid() + ".db;Version=3;New=True";
|
||||
var dbProvider = ProviderFactory.GetProvider(connectionString, "System.Data.SQLite");
|
||||
var repo = new SimpleRepository(dbProvider, SimpleRepositoryOptions.RunMigrations);
|
||||
var sqliteDatabase = new SQLiteTransformationProvider(new SQLiteDialect(), connectionString);
|
||||
|
||||
repo.Add(new TestRepoType2() { Value = "dummy" });
|
||||
|
||||
var repositoryProvider = new RepositoryProvider();
|
||||
var typeSchema = repositoryProvider.GetSchemaFromType(typeof(TestRepoType));
|
||||
var columns = repositoryProvider.GetColumnsFromDatabase(sqliteDatabase, "TestRepoType2s");
|
||||
|
||||
|
||||
var deletedColumns = repositoryProvider.GetNewColumns(typeSchema, columns);
|
||||
|
||||
|
||||
deletedColumns.Should().HaveCount(1);
|
||||
Assert.AreEqual("NewName", deletedColumns[0].Name.Trim('[', ']'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class TestRepoType
|
||||
{
|
||||
[SubSonicPrimaryKey]
|
||||
public int TestId { get; set; }
|
||||
|
||||
[SubSonicColumnNameOverride("NewName")]
|
||||
public Boolean BaddBoolean { get; set; }
|
||||
|
||||
|
||||
public string Value { get; set; }
|
||||
|
||||
[SubSonicIgnore]
|
||||
public Boolean BaddBooleanIgnored { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class TestRepoType2
|
||||
{
|
||||
[SubSonicPrimaryKey]
|
||||
public int TestId { get; set; }
|
||||
|
||||
public string Value { get; set; }
|
||||
|
||||
[SubSonicIgnore]
|
||||
public Boolean BaddBooleanIgnored { get; set; }
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -22,7 +22,7 @@ namespace NzbDrone.Core.Test
|
||||
private readonly List<int> seriesIds = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
|
||||
private readonly List<Episode> episodes = new List<Episode>();
|
||||
private readonly List<EpisodeFile> files = new List<EpisodeFile>();
|
||||
private readonly IRepository repo = MockLib.GetEmptyRepository();
|
||||
|
||||
|
||||
[TestFixtureSetUp]
|
||||
public new void Setup()
|
||||
@@ -40,7 +40,7 @@ namespace NzbDrone.Core.Test
|
||||
.With(s => s.Monitored = true)
|
||||
.Build();
|
||||
|
||||
repo.Add(series);
|
||||
//repo.Add(series);
|
||||
|
||||
foreach (var _seasonNumber in seasonsNumbers)
|
||||
{
|
||||
@@ -83,8 +83,8 @@ namespace NzbDrone.Core.Test
|
||||
|
||||
}
|
||||
|
||||
repo.AddMany(episodes);
|
||||
repo.AddMany(files);
|
||||
//repo.AddMany(episodes);
|
||||
//repo.AddMany(files);
|
||||
}
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace NzbDrone.Core.Test
|
||||
public void get_episode_file_count_x100()
|
||||
{
|
||||
var mocker = new AutoMoq.AutoMoqer();
|
||||
mocker.SetConstant(repo);
|
||||
//mocker.SetConstant(repo);
|
||||
mocker.SetConstant(mocker.Resolve<EpisodeProvider>());
|
||||
var mediaProvider = mocker.Resolve<MediaFileProvider>();
|
||||
|
||||
@@ -168,7 +168,7 @@ namespace NzbDrone.Core.Test
|
||||
public void get_season_count_x5000()
|
||||
{
|
||||
var mocker = new AutoMoq.AutoMoqer();
|
||||
mocker.SetConstant(repo);
|
||||
//mocker.SetConstant(repo);
|
||||
var provider = mocker.Resolve<EpisodeProvider>();
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ namespace NzbDrone.Core.Test
|
||||
public void get_episode_file_count_x10()
|
||||
{
|
||||
var mocker = new AutoMoq.AutoMoqer();
|
||||
mocker.SetConstant(repo);
|
||||
//mocker.SetConstant(repo);
|
||||
mocker.SetConstant(mocker.Resolve<EpisodeProvider>());
|
||||
var provider = mocker.Resolve<MediaFileProvider>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user