Merge branch 'master' of git://github.com/kayone/NzbDrone

pull/4/head
Mark McDowall 14 years ago
commit 71a123401e

File diff suppressed because it is too large Load Diff

Binary file not shown.

@ -1,11 +1,9 @@
using AutoMoq;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
using SubSonic.Repository;
namespace NzbDrone.Core.Test
{
@ -41,6 +39,7 @@ namespace NzbDrone.Core.Test
mocker.SetConstant(db);
db.Insert(new Config { Key = key, Value = value });
db.Insert(new Config { Key = "Other Key", Value = "OtherValue" });
//Act
var result = mocker.Resolve<ConfigProvider>().GetValue(key, "");
@ -69,7 +68,7 @@ namespace NzbDrone.Core.Test
}
[Test]
public void New_value_should_update_old_value()
public void New_value_should_update_old_value_new_value()
{
const string key = "MY_KEY";
const string originalValue = "OLD_VALUE";
@ -90,5 +89,26 @@ namespace NzbDrone.Core.Test
db.Fetch<Config>().Should().HaveCount(1);
}
[Test]
public void New_value_should_update_old_value_same_value()
{
const string key = "MY_KEY";
const string value = "OLD_VALUE";
var mocker = new AutoMoqer();
var db = MockLib.GetEmptyDatabase();
mocker.SetConstant(db);
//Act
mocker.Resolve<ConfigProvider>().SetValue(key, value);
mocker.Resolve<ConfigProvider>().SetValue(key, value);
var result = mocker.Resolve<ConfigProvider>().GetValue(key, "");
//Assert
result.Should().Be(value);
db.Fetch<Config>().Should().HaveCount(1);
}
}
}

@ -1,8 +1,6 @@
// ReSharper disable RedundantUsingDirective
using System;
using System.Linq;
using System.Collections.Generic;
using System.Threading;
using AutoMoq;
using FizzWare.NBuilder;
using Moq;

@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using AutoMoq;
using FizzWare.NBuilder;
using Moq;

@ -1,20 +1,16 @@
// ReSharper disable RedundantUsingDirective
using System;
using System.Linq;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Linq;
using AutoMoq;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using PetaPoco;
using SubSonic.Repository;
using TvdbLib.Data;
namespace NzbDrone.Core.Test

@ -1,9 +1,8 @@
// ReSharper disable RedundantUsingDirective
using System;
using AutoMoq;
using Moq;
using System;
using NUnit.Framework;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test
{

@ -1,7 +1,7 @@
// ReSharper disable RedundantUsingDirective
using System;
using System.Linq;
using System.Collections.Generic;
using System.Linq;
using NLog;
using NLog.Targets;
using NUnit.Framework;

@ -6,13 +6,10 @@ using System.Linq;
using FizzWare.NBuilder;
using Moq;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Instrumentation;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using PetaPoco;
using SubSonic.DataProviders;
using SubSonic.Repository;
namespace NzbDrone.Core.Test.Framework
{
@ -37,32 +34,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 +42,9 @@ namespace NzbDrone.Core.Test.Framework
{
fileName = Guid.NewGuid() + ".db";
}
var connectionString = Connection.GetConnectionString(fileName);
var database = Connection.GetPetaPocoDb(connectionString);
return database;
@ -121,12 +92,5 @@ namespace NzbDrone.Core.Test.Framework
.WhereAll().Have(c => c.EpisodeNumber = epNumber.Generate())
.Build();
}
private static void ForceMigration(IRepository repository)
{
repository.All<EpisodeFile>().Count();
repository.All<QualityProfile>().Count();
repository.All<History>().Count();
}
}
}

@ -1,5 +1,4 @@
using NUnit;
using NUnit.Framework;
using NUnit.Framework;
namespace NzbDrone.Core.Test.Framework
{

@ -1,6 +1,5 @@
// ReSharper disable RedundantUsingDirective
using System;
using System.Collections.Generic;
using System.Linq;
using AutoMoq;
using FizzWare.NBuilder;
@ -11,7 +10,6 @@ using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using SubSonic.Repository;
namespace NzbDrone.Core.Test
{

@ -1,7 +1,6 @@
// ReSharper disable RedundantUsingDirective
using System.Linq;
using System;
using System.Collections.Generic;
using System.Threading;
using AutoMoq;
using FizzWare.NBuilder;
using Moq;
@ -11,7 +10,6 @@ using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Jobs;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
using System;
namespace NzbDrone.Core.Test
{

@ -1,22 +1,16 @@
// ReSharper disable RedundantUsingDirective
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.ServiceModel.Syndication;
using AutoMoq;
using FizzWare.NBuilder;
using Moq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.ExternalNotification;
using NzbDrone.Core.Providers.Indexer;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using FluentAssertions;
namespace NzbDrone.Core.Test
{
@ -158,7 +152,7 @@ namespace NzbDrone.Core.Test
return "http://www.google.com";
}
protected override Model.EpisodeParseResult CustomParser(SyndicationItem item, Model.EpisodeParseResult currentResult)
protected override EpisodeParseResult CustomParser(SyndicationItem item, EpisodeParseResult currentResult)
{
if (currentResult == null) currentResult = new EpisodeParseResult();
currentResult.Language = LanguageType.Finnish;

@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.ServiceModel.Syndication;
using System.Text;
using AutoMoq;
using FizzWare.NBuilder;
using FluentAssertions;

@ -1,9 +1,6 @@
// ReSharper disable RedundantUsingDirective
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.ServiceModel.Syndication;
using AutoMoq;
using FizzWare.NBuilder;
using FluentAssertions;
@ -11,9 +8,6 @@ using Moq;
using NUnit.Framework;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.ExternalNotification;
using NzbDrone.Core.Providers.Indexer;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;

@ -1,17 +1,13 @@
// ReSharper disable RedundantUsingDirective
using System;
using System.Linq;
using FizzWare.NBuilder;
using FluentAssertions;
using NLog;
using NLog.Config;
using NUnit.Framework;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Instrumentation;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test
{
[TestFixture]

@ -2,8 +2,8 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq.Expressions;
using System.Linq;
using System.Linq.Expressions;
using AutoMoq;
using FizzWare.NBuilder;
using FluentAssertions;
@ -18,7 +18,6 @@ using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
using PetaPoco;
using SubSonic.Repository;
namespace NzbDrone.Core.Test
{
@ -213,10 +212,10 @@ namespace NzbDrone.Core.Test
//Mocks
var mocker = new AutoMoqer();
mocker.GetMock<IRepository>()
.Setup(r => r.Exists(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(false).Verifiable();
mocker.GetMock<IRepository>()
.Setup(r => r.Add(It.IsAny<EpisodeFile>())).Returns(0).Verifiable();
mocker.GetMock<IDatabase>()
.Setup(r => r.Exists<EpisodeFile>(It.IsAny<string>())).Returns(false).Verifiable();
mocker.GetMock<IDatabase>()
.Setup(r => r.Insert(It.IsAny<EpisodeFile>())).Returns(0).Verifiable();
mocker.GetMock<EpisodeProvider>()
.Setup(e => e.GetEpisode(fakeSeries.SeriesId, airDate)).Returns(fakeEpisode).
@ -299,7 +298,7 @@ namespace NzbDrone.Core.Test
//Assert
mocker.VerifyAllMocks();
Assert.IsNull(result);
mocker.GetMock<IRepository>().Verify(r => r.Add(result), Times.Never());
mocker.GetMock<IDatabase>().Verify(r => r.Insert(result), Times.Never());
ExceptionVerification.ExcpectedWarns(1);
}

@ -1,13 +1,8 @@
// ReSharper disable RedundantUsingDirective
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using AutoMoq;
using FizzWare.NBuilder;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;

@ -1,19 +1,13 @@
// ReSharper disable RedundantUsingDirective
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq.Expressions;
using System.Linq;
using AutoMoq;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.Jobs;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;

@ -75,7 +75,6 @@
<Reference Include="pnunit.framework">
<HintPath>..\packages\NUnit.2.5.10.11092\lib\pnunit.framework.dll</HintPath>
</Reference>
<Reference Include="SubSonic.Core, Version=3.0.0.3, Culture=neutral, processorArchitecture=x86" />
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
@ -116,7 +115,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 +126,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" />

@ -154,6 +154,7 @@ namespace NzbDrone.Core.Test
[TestCase("The Daily Show - 2011-04-12 - Gov. Deval Patrick", "The.Daily.Show", 2011, 04, 12)]
[TestCase("2011.01.10 - Denis Leary - HD TV.mkv", "", 2011, 1, 10)]
[TestCase("2011.03.13 - Denis Leary - HD TV.mkv", "", 2011, 3, 13)]
[TestCase("The Tonight Show with Jay Leno - 2011-06-16 - Larry David, \"Bachelorette\" Ashley Hebert, Pitbull with Ne-Yo", "The Tonight Show with Jay Leno", 2011, 3, 13)]
public void episode_daily_parse(string postTitle, string title, int year, int month, int day)
{
var result = Parser.ParseEpisodeInfo(postTitle);

@ -1,7 +1,6 @@
// ReSharper disable RedundantUsingDirective
using System;
using System.Collections.Generic;
using System.Linq;
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using FluentAssertions;
using NUnit.Framework;
using NUnit.Framework;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;

@ -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; }
}
}

@ -9,7 +9,6 @@ using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
using SubSonic.Repository;
namespace NzbDrone.Core.Test
{

@ -1,19 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using AutoMoq;
using AutoMoq;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
using SubSonic.Repository;
using TvdbLib.Data;
namespace NzbDrone.Core.Test
{

@ -1,16 +1,16 @@
// ReSharper disable RedundantUsingDirective
using System;
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Test.Framework;
using TvdbLib.Data;
using System.Collections.Generic;
namespace NzbDrone.Core.Test
{
[NUnit.Framework.TestFixture]
[TestFixture]
// ReSharper disable InconsistentNaming
public class TvDbProviderTest : TestBase
{

@ -1,15 +1,10 @@
// ReSharper disable RedundantUsingDirective
using System;
using System.Collections.Generic;
using System.Linq;
using AutoMoq;
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test

@ -2,13 +2,13 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using AutoMoq;
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
using SubSonic.Repository;
namespace NzbDrone.Core.Test
{
@ -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);
}
@ -139,8 +139,8 @@ namespace NzbDrone.Core.Test
[Test]
public void get_episode_file_count_x100()
{
var mocker = new AutoMoq.AutoMoqer();
mocker.SetConstant(repo);
var mocker = new AutoMoqer();
//mocker.SetConstant(repo);
mocker.SetConstant(mocker.Resolve<EpisodeProvider>());
var mediaProvider = mocker.Resolve<MediaFileProvider>();
@ -167,8 +167,8 @@ namespace NzbDrone.Core.Test
[Test]
public void get_season_count_x5000()
{
var mocker = new AutoMoq.AutoMoqer();
mocker.SetConstant(repo);
var mocker = new AutoMoqer();
//mocker.SetConstant(repo);
var provider = mocker.Resolve<EpisodeProvider>();
@ -194,8 +194,8 @@ namespace NzbDrone.Core.Test
[Test]
public void get_episode_file_count_x10()
{
var mocker = new AutoMoq.AutoMoqer();
mocker.SetConstant(repo);
var mocker = new AutoMoqer();
//mocker.SetConstant(repo);
mocker.SetConstant(mocker.Resolve<EpisodeProvider>());
var provider = mocker.Resolve<MediaFileProvider>();

@ -1,7 +1,7 @@
using System;
using System.Linq;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Web.Hosting;
using Ninject;
using NLog;
@ -12,7 +12,6 @@ using NzbDrone.Core.Providers.ExternalNotification;
using NzbDrone.Core.Providers.Indexer;
using NzbDrone.Core.Providers.Jobs;
using PetaPoco;
using SubSonic.Repository;
namespace NzbDrone.Core
{
@ -69,10 +68,9 @@ namespace NzbDrone.Core
_kernel = new StandardKernel();
_kernel.Bind<IDatabase>().ToMethod(c => Connection.GetPetaPocoDb(Connection.MainConnectionString)).InRequestScope();
_kernel.Bind<IDatabase>().ToMethod(c => Connection.GetPetaPocoDb(Connection.LogConnectionString)).WhenInjectedInto<SubsonicTarget>().InSingletonScope();
_kernel.Bind<IDatabase>().ToMethod(c => Connection.GetPetaPocoDb(Connection.MainConnectionString, false)).WhenInjectedInto<IJob>().InSingletonScope();
_kernel.Bind<IDatabase>().ToMethod(c => Connection.GetPetaPocoDb(Connection.LogConnectionString, false)).WhenInjectedInto<SubsonicTarget>().InSingletonScope();
_kernel.Bind<IDatabase>().ToMethod(c => Connection.GetPetaPocoDb(Connection.LogConnectionString)).WhenInjectedInto<LogProvider>().InRequestScope();
_kernel.Bind<IRepository>().ToConstant(Connection.CreateSimpleRepository(Connection.MainConnectionString)).InSingletonScope();
}
}

@ -5,9 +5,6 @@ using System.Data.SQLite;
using System.IO;
using MvcMiniProfiler.Data;
using PetaPoco;
using SubSonic.DataProviders;
using SubSonic.DataProviders.SQLite;
using SubSonic.Repository;
namespace NzbDrone.Core.Datastore
{
@ -18,6 +15,7 @@ namespace NzbDrone.Core.Datastore
static Connection()
{
if (!AppDataPath.Exists) AppDataPath.Create();
Database.Mapper = new CustomeMapper();
}
@ -42,51 +40,23 @@ namespace NzbDrone.Core.Datastore
}
}
public static IDataProvider GetDataProvider(string connectionString)
{
return new ProfiledSQLiteProvider(connectionString, "System.Data.SQLite");
}
public static IRepository CreateSimpleRepository(IDataProvider dataProvider)
{
return new SimpleRepository(dataProvider, SimpleRepositoryOptions.RunMigrations);
}
public static IRepository CreateSimpleRepository(string connectionString)
{
return new SimpleRepository(GetDataProvider(connectionString), SimpleRepositoryOptions.RunMigrations);
}
public static IDatabase GetPetaPocoDb(string connectionString)
public static IDatabase GetPetaPocoDb(string connectionString, Boolean profiled = true)
{
MigrationsHelper.Run(connectionString, true);
DbConnection connection = new SQLiteConnection(connectionString);
if (profiled)
{
//connection = ProfiledDbConnection.Get(connection);
}
var profileConnection = ProfiledDbConnection.Get(new SQLiteConnection(connectionString));
Database.Mapper = new CustomeMapper();
var db = new Database(profileConnection);
var db = new Database(connection);
if (profileConnection.State != ConnectionState.Open)
profileConnection.Open();
if (connection.State != ConnectionState.Open)
connection.Open();
return db;
}
}
public class ProfiledSQLiteProvider : SQLiteProvider
{
public ProfiledSQLiteProvider(string connectionString, string providerName)
: base(connectionString, providerName)
{
}
public override System.Data.Common.DbConnection CreateConnection(string connectionString)
{
return ProfiledDbConnection.Get(base.CreateConnection(connectionString));
}
}
}

@ -4,33 +4,6 @@ using Migrator.Framework;
namespace NzbDrone.Core.Datastore.Migrations
{
[Migration(20110523)]
public class Migration20110523 : Migration
{
public override void Up()
{
Database.RemoveTable(RepositoryProvider.JobsSchema.Name);
}
public override void Down()
{
throw new NotImplementedException();
}
}
[Migration(20110603)]
public class Migration20110603 : Migration
{
public override void Up()
{
Database.RemoveTable("Seasons");
}
public override void Down()
{
throw new NotImplementedException();
}
}
[Migration(20110604)]
public class Migration20110616 : Migration
@ -40,13 +13,13 @@ namespace NzbDrone.Core.Datastore.Migrations
Database.AddTable("Series", new[]
{
new Column("SeriesId", DbType.Int32, ColumnProperty.PrimaryKey),
new Column("Title", DbType.String, ColumnProperty.NotNull, String.Empty),
new Column("CleanTitle", DbType.String, ColumnProperty.NotNull, String.Empty),
new Column("Title", DbType.String, ColumnProperty.Null),
new Column("CleanTitle", DbType.String, ColumnProperty.Null),
new Column("Status", DbType.String, ColumnProperty.Null),
new Column("Overview", DbType.String, ColumnProperty.NotNull, String.Empty),
new Column("Overview", DbType.String, ColumnProperty.Null),
new Column("AirsDayOfWeek", DbType.Int16, ColumnProperty.Null),
new Column("AirTimes", DbType.String, ColumnProperty.NotNull, String.Empty),
new Column("Language", DbType.String, ColumnProperty.NotNull, String.Empty),
new Column("AirTimes", DbType.String, ColumnProperty.Null),
new Column("Language", DbType.String, ColumnProperty.Null),
new Column("Path", DbType.String, ColumnProperty.NotNull),
new Column("Monitored", DbType.Boolean, ColumnProperty.NotNull),
new Column("QualityProfileId", DbType.Int16, ColumnProperty.NotNull),
@ -62,9 +35,9 @@ namespace NzbDrone.Core.Datastore.Migrations
new Column("SeriesId", DbType.Int32, ColumnProperty.NotNull),
new Column("SeasonNumber", DbType.Int16, ColumnProperty.NotNull),
new Column("EpisodeNumber", DbType.Int16, ColumnProperty.NotNull),
new Column("Title", DbType.String, ColumnProperty.NotNull, String.Empty),
new Column("Overview", DbType.String, ColumnProperty.NotNull, String.Empty),
new Column("Ignored", DbType.Boolean, ColumnProperty.NotNull, false),
new Column("Title", DbType.String, ColumnProperty.Null),
new Column("Overview", DbType.String, ColumnProperty.Null),
new Column("Ignored", DbType.Boolean, ColumnProperty.NotNull),
new Column("EpisodeFileId", DbType.Int32, ColumnProperty.Null),
new Column("AirDate", DbType.DateTime, ColumnProperty.Null),
new Column("GrabDate", DbType.DateTime, ColumnProperty.Null)

@ -1,16 +1,7 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using Migrator.Framework;
using NLog;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using SubSonic.Extensions;
using SubSonic.Repository;
using SubSonic.Schema;
namespace NzbDrone.Core.Datastore
{
@ -18,10 +9,13 @@ namespace NzbDrone.Core.Datastore
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public static bool IsMigrated { get; private set; }
public static readonly Dictionary<String, String> _migrated = new Dictionary<string, string>();
public static void Run(string connetionString, bool trace)
{
if (_migrated.ContainsKey(connetionString)) return;
_migrated.Add(connetionString, string.Empty);
Logger.Info("Preparing run database migration");
try
@ -52,63 +46,6 @@ namespace NzbDrone.Core.Datastore
}
}
public static void ForceSubSonicMigration(IRepository repository)
{
repository.Single<QualityProfile>(1);
repository.Single<IndexerSetting>(1);
repository.Single<SceneMapping>(1);
}
public static void RemoveDeletedColumns(ITransformationProvider transformationProvider)
{
var provider = new RepositoryProvider();
var repoTypes = provider.GetRepositoryTypes();
foreach (var repoType in repoTypes)
{
var typeSchema = provider.GetSchemaFromType(repoType);
if (transformationProvider.TableExists(typeSchema.Name))
{
var dbColumns = provider.GetColumnsFromDatabase(transformationProvider, typeSchema.Name);
var deletedColumns = provider.GetDeletedColumns(typeSchema, dbColumns);
foreach (var deletedColumn in deletedColumns)
{
Logger.Info("Removing column '{0}' from '{1}'", deletedColumn.Name, repoType.Name);
transformationProvider.RemoveColumn(typeSchema.Name, deletedColumn.Name);
}
}
}
}
public static void AddNewColumns(ITransformationProvider transformationProvider)
{
var provider = new RepositoryProvider();
var repoTypes = provider.GetRepositoryTypes();
foreach (var repoType in repoTypes)
{
var typeSchema = provider.GetSchemaFromType(repoType);
if (transformationProvider.TableExists(typeSchema.Name))
{
var dbColumns = provider.GetColumnsFromDatabase(transformationProvider, typeSchema.Name);
var newColumns = provider.GetNewColumns(typeSchema, dbColumns);
foreach (var newColumn in newColumns)
{
Logger.Info("Adding column '{0}' to '{1}'", newColumn.Name, repoType.Name);
transformationProvider.AddColumn(typeSchema.Name, newColumn);
}
}
}
}
}

@ -13,16 +13,17 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data.Common;
using System.Data;
using System.Text.RegularExpressions;
using System.Data.Common;
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Linq.Expressions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
namespace PetaPoco
{
@ -485,12 +486,12 @@ namespace PetaPoco
}
// Expand collections to parameter lists
if ((arg_val as System.Collections.IEnumerable) != null &&
if ((arg_val as IEnumerable) != null &&
(arg_val as string) == null &&
(arg_val as byte[]) == null)
{
var sb = new StringBuilder();
foreach (var i in arg_val as System.Collections.IEnumerable)
foreach (var i in arg_val as IEnumerable)
{
sb.Append((sb.Length == 0 ? "@" : ",@") + args_dest.Count.ToString());
args_dest.Add(i);
@ -510,9 +511,9 @@ namespace PetaPoco
void AddParam(IDbCommand cmd, object item, string ParameterPrefix)
{
// Convert value to from poco type to db type
if (Database.Mapper != null && item != null)
if (Mapper != null && item != null)
{
var fn = Database.Mapper.GetToDbConverter(item.GetType());
var fn = Mapper.GetToDbConverter(item.GetType());
if (fn != null)
item = fn(item);
}
@ -625,8 +626,8 @@ namespace PetaPoco
// Override this to log/capture exceptions
public virtual void OnException(Exception x)
{
System.Diagnostics.Debug.WriteLine(x.ToString());
System.Diagnostics.Debug.WriteLine(LastCommand);
Debug.WriteLine(x.ToString());
Debug.WriteLine(LastCommand);
}
// Override this to log commands, or modify command before execution
@ -1120,7 +1121,7 @@ namespace PetaPoco
// Various cached stuff
static Dictionary<string, object> MultiPocoFactories = new Dictionary<string, object>();
static Dictionary<string, object> AutoMappers = new Dictionary<string, object>();
static System.Threading.ReaderWriterLockSlim RWLock = new System.Threading.ReaderWriterLockSlim();
static ReaderWriterLockSlim RWLock = new ReaderWriterLockSlim();
// Get (or create) the multi-poco factory for a query
Func<IDataReader, object, TRet> GetMultiPocoFactory<TRet>(Type[] types, string sql, IDataReader r)
@ -1954,7 +1955,7 @@ namespace PetaPoco
#endif
return ForType(t);
}
static System.Threading.ReaderWriterLockSlim RWLock = new System.Threading.ReaderWriterLockSlim();
static ReaderWriterLockSlim RWLock = new ReaderWriterLockSlim();
public static PocoData ForType(Type t)
{
#if !PETAPOCO_NO_DYNAMIC
@ -2018,8 +2019,8 @@ namespace PetaPoco
TableInfo.AutoIncrement = TableInfo.AutoIncrement ? !TableInfo.PrimaryKey.Contains(',') : TableInfo.AutoIncrement;
// Call column mapper
if (Database.Mapper != null)
Database.Mapper.GetTableInfo(t, TableInfo);
if (Mapper != null)
Mapper.GetTableInfo(t, TableInfo);
// Work out bound properties
bool ExplicitColumns = t.GetCustomAttributes(typeof(ExplicitColumnsAttribute), true).Length > 0;
@ -2055,7 +2056,7 @@ namespace PetaPoco
if (pc.ColumnName == null)
{
pc.ColumnName = pi.Name;
if (Database.Mapper != null && !Database.Mapper.MapPropertyToColumn(pi, ref pc.ColumnName, ref pc.ResultColumn))
if (Mapper != null && !Mapper.MapPropertyToColumn(pi, ref pc.ColumnName, ref pc.ResultColumn))
continue;
}
@ -2307,12 +2308,12 @@ namespace PetaPoco
Func<object, object> converter = null;
// Get converter from the mapper
if (Database.Mapper != null)
if (Mapper != null)
{
DestinationInfo destinationInfo = pc != null
? new DestinationInfo(pc.PropertyInfo)
: new DestinationInfo(dstType);
converter = Database.Mapper.GetFromDbConverter(destinationInfo, srcType);
converter = Mapper.GetFromDbConverter(destinationInfo, srcType);
}
// Standard DateTime->Utc mapper

@ -1,98 +0,0 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using Migrator.Providers;
using Migrator.Providers.SQLite;
using NzbDrone.Core.Repository;
using SubSonic.DataProviders;
using SubSonic.Extensions;
using SubSonic.Schema;
using Migrator.Framework;
namespace NzbDrone.Core.Datastore
{
public class RepositoryProvider
{
public static readonly ITable EpisodesSchema = new RepositoryProvider().GetSchemaFromType(typeof(Episode));
public static readonly ITable SeriesSchema = new RepositoryProvider().GetSchemaFromType(typeof(Series));
public static readonly ITable EpisodeFilesSchema = new RepositoryProvider().GetSchemaFromType(typeof(EpisodeFile));
public static readonly ITable JobsSchema = new RepositoryProvider().GetSchemaFromType(typeof(JobSetting));
public virtual IList<Type> GetRepositoryTypes()
{
var coreAssembly = Assembly.GetExecutingAssembly();
var repoTypes = coreAssembly.GetTypes().Where(t => !String.IsNullOrWhiteSpace(t.Namespace) && t.Namespace.StartsWith("NzbDrone.Core.Repository"));
repoTypes = repoTypes.Where(r => !r.IsEnum);
return repoTypes.ToList();
}
public virtual ITable GetSchemaFromType(Type type)
{
return type.ToSchemaTable(Connection.GetDataProvider(Connection.MainConnectionString));
}
public virtual Column[] GetColumnsFromDatabase(ITransformationProvider database, string tableName)
{
return database.GetColumns(tableName);
}
public virtual List<Column> GetDeletedColumns(ITable typeSchema, Column[] dbColumns)
{
var deleteColumns = new List<Column>();
foreach (var dbColumn in dbColumns)
{
if (!typeSchema.Columns.ToList().Exists(c => c.Name == dbColumn.Name.Trim('[', ']')))
{
deleteColumns.Add(dbColumn);
}
}
return deleteColumns;
}
public virtual List<Column> GetNewColumns(ITable typeSchema, Column[] dbColumns)
{
var newColumns = new List<Column>();
foreach (var typeColumn in typeSchema.Columns)
{
if (!dbColumns.ToList().Exists(c => c.Name.Trim('[', ']') == typeColumn.Name))
{
newColumns.Add(ConvertToMigratorColumn(typeColumn));
}
}
return newColumns;
}
public virtual Column ConvertToMigratorColumn(SubSonic.Schema.IColumn subsonicColumns)
{
var migColumn = new Column(subsonicColumns.Name, subsonicColumns.DataType);
if (subsonicColumns.IsPrimaryKey)
{
migColumn.ColumnProperty = ColumnProperty.PrimaryKey;
}
if (subsonicColumns.IsNullable)
{
migColumn.ColumnProperty = migColumn.ColumnProperty | ColumnProperty.Null;
}
else
{
migColumn.ColumnProperty = migColumn.ColumnProperty | ColumnProperty.NotNull;
migColumn.DefaultValue = false;
}
return migColumn;
}
}
}

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Migrator.Framework;
using Migrator.Providers.SQLite;

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Helpers
{

@ -1,6 +1,5 @@
using System;
using PetaPoco;
using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Instrumentation
{

@ -1,7 +1,6 @@
using System.Diagnostics;
using System.IO;
using Ninject;
using Ninject.Activation;
using NLog;
using NLog.Config;

@ -1,8 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using NLog;
using PetaPoco;
using SubSonic.Repository;
namespace NzbDrone.Core.Instrumentation
{

@ -2,7 +2,6 @@
using NLog;
using NLog.Targets;
using PetaPoco;
using SubSonic.Repository;
namespace NzbDrone.Core.Instrumentation
{

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model
namespace NzbDrone.Core.Model
{
public class ConnectionInfoModel
{

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Core.Model
{

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model
namespace NzbDrone.Core.Model
{
public enum ExternalNotificationType
{

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Core.Model
@ -22,19 +19,19 @@ namespace NzbDrone.Core.Model
public int CompareTo(Quality other)
{
if (other.QualityType > this.QualityType)
if (other.QualityType > QualityType)
return -1;
if (other.QualityType < this.QualityType)
if (other.QualityType < QualityType)
return 1;
if (other.QualityType == this.QualityType && other.Proper == this.Proper)
if (other.QualityType == QualityType && other.Proper == Proper)
return 0;
if (this.Proper && !other.Proper)
if (Proper && !other.Proper)
return 1;
if (!this.Proper && other.Proper)
if (!Proper && other.Proper)
return -1;
return 0;

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Core.Model
namespace NzbDrone.Core.Model
{
public class SabnzbdInfoModel
{

@ -1,6 +1,4 @@
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Core.Model
namespace NzbDrone.Core.Model
{
public class SeasonParseResult
{

@ -141,10 +141,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libraries\NLog.dll</HintPath>
</Reference>
<Reference Include="SubSonic.Core, Version=3.0.0.3, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libraries\SubSonic.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.ComponentModel.DataAnnotations" />
@ -172,7 +168,6 @@
<Compile Include="Datastore\MigrationsHelper.cs" />
<Compile Include="Datastore\CustomeMapper.cs" />
<Compile Include="Datastore\Migrations\Migration.cs" />
<Compile Include="Datastore\RepositoryProvider.cs" />
<Compile Include="Datastore\SqliteProvider.cs" />
<Compile Include="Helpers\EpisodeRenameHelper.cs" />
<Compile Include="Helpers\EpisodeSortingHelper.cs" />

@ -4,10 +4,8 @@ using System.IO;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Text;
using System.Text.RegularExpressions;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers
{

@ -1,12 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository;
using PetaPoco;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers.Core
{
@ -280,7 +278,7 @@ namespace NzbDrone.Core.Providers.Core
{
string value;
var dbValue = _database.SingleOrDefault<Config>(key);
var dbValue = _database.SingleOrDefault<Config>("WHERE Key=@0", key);
if (dbValue != null && !String.IsNullOrEmpty(dbValue.Value))
return dbValue.Value;

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace NzbDrone.Core.Providers.Core
{

@ -3,7 +3,6 @@ using System.IO;
using System.Net;
using NLog;
namespace NzbDrone.Core.Providers.Core
{
public class HttpProvider

@ -1,13 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.Indexer;
using NzbDrone.Core.Repository;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers
{

@ -1,13 +1,11 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository;
using PetaPoco;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers
{

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NLog;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;

@ -1,15 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.ExternalNotification;
using NzbDrone.Core.Repository;
using PetaPoco;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers
{

@ -5,7 +5,6 @@ using System.ServiceModel.Syndication;
using Ninject;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.ExternalNotification;
namespace NzbDrone.Core.Providers.Indexer
{

@ -1,12 +1,8 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.ServiceModel.Syndication;
using Ninject;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.ExternalNotification;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers.Indexer
{

@ -1,12 +1,8 @@
using System;
using System.Collections.Generic;
using System.Net;
using System.ServiceModel.Syndication;
using Ninject;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.ExternalNotification;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers.Indexer
{

@ -1,11 +1,7 @@
using System.Collections.Generic;
using System.Net;
using System.ServiceModel.Syndication;
using Ninject;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.ExternalNotification;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers.Indexer
{

@ -1,11 +1,7 @@
using System;
using System.IO;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Repository;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers.Jobs
{

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ninject;
using NLog;
using NzbDrone.Core.Model.Notification;

@ -1,12 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers.Indexer;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Providers.Jobs

@ -8,7 +8,6 @@ using NLog;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Repository;
using PetaPoco;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers.Jobs
{

@ -1,13 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Ninject;
using NLog;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Providers.Jobs
{

@ -1,7 +1,4 @@
using System;
using System.IO;
using System.Linq;
using Ninject;
using Ninject;
using NLog;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers.Core;

@ -1,5 +1,5 @@
using System.Linq;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Ninject;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Repository;

@ -1,7 +1,4 @@
using System.Linq;
using System.Collections.Generic;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Model.Notification;
namespace NzbDrone.Core.Providers.Jobs
{

@ -5,7 +5,6 @@ using Ninject;
using NLog;
using NzbDrone.Core.Repository.Quality;
using PetaPoco;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers
{

@ -1,13 +1,11 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using PetaPoco;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers
{

@ -1,14 +1,10 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using NLog;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using PetaPoco;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers
{

@ -114,7 +114,7 @@ namespace NzbDrone.Core.Providers
return GetSeries(seriesId.Value);
}
return _database.Single<Series>("WHERE CleanTitle = @0", normalizeTitle);
return _database.FirstOrDefault<Series>("WHERE CleanTitle = @0", normalizeTitle);
}
public virtual void UpdateSeries(Series series)

@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ninject;
namespace NzbDrone.Core.Providers

@ -1,6 +1,6 @@
using System;
using System.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using NLog;
using TvdbLib;

@ -5,7 +5,6 @@ using Ninject;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository;
using PetaPoco;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers
{

@ -4,7 +4,6 @@ using System.Linq;
using System.Xml.Linq;
using Ninject;
using NLog;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers

@ -1,5 +1,4 @@
using PetaPoco;
using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Repository
{

@ -2,8 +2,6 @@
using System.Collections.Generic;
using NzbDrone.Core.Model;
using PetaPoco;
using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Repository
{
@ -11,7 +9,7 @@ namespace NzbDrone.Core.Repository
[PrimaryKey("EpisodeId", autoIncrement = true)]
public class Episode
{
[SubSonicPrimaryKey]
public virtual int EpisodeId { get; set; }
public virtual int? TvDbEpisodeId { get; set; }
@ -23,12 +21,11 @@ namespace NzbDrone.Core.Repository
public virtual string Title { get; set; }
public virtual DateTime AirDate { get; set; }
[SubSonicLongString]
public virtual string Overview { get; set; }
public virtual Boolean Ignored { get; set; }
[SubSonicIgnore]
[Ignore]
public Boolean IsDailyEpisode
{
@ -47,7 +44,7 @@ namespace NzbDrone.Core.Repository
/// </remarks>
public virtual DateTime? GrabDate { get; set; }
[SubSonicIgnore]
[Ignore]
public EpisodeStatusType Status
{
@ -72,15 +69,15 @@ namespace NzbDrone.Core.Repository
}
}
[SubSonicToOneRelation(ThisClassContainsJoinKey = true)]
[Ignore]
public virtual Series Series { get; set; }
[SubSonicToOneRelation(ThisClassContainsJoinKey = true)]
[Ignore]
public virtual EpisodeFile EpisodeFile { get; set; }
[SubSonicToManyRelation]
[Ignore]
public virtual IList<History> Histories { get; protected set; }

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PetaPoco;
using PetaPoco;
namespace NzbDrone.Core.Repository
{

@ -1,8 +1,6 @@
using System;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository.Quality;
using PetaPoco;
using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Repository
{

@ -1,6 +1,5 @@
using System;
using PetaPoco;
using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Repository
{
@ -8,7 +7,6 @@ namespace NzbDrone.Core.Repository
[PrimaryKey("Id", autoIncrement = true)]
public class JobSetting
{
[SubSonicPrimaryKey(true)]
public Int32 Id { get; set; }
public Boolean Enable { get; set; }

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using PetaPoco;
using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Repository.Quality
{
@ -11,7 +10,7 @@ namespace NzbDrone.Core.Repository.Quality
[PrimaryKey("QualityProfileId", autoIncrement = true)]
public class QualityProfile
{
[SubSonicPrimaryKey]
public virtual int QualityProfileId { get; set; }
[Required(ErrorMessage = "A Name is Required")]
@ -20,12 +19,10 @@ namespace NzbDrone.Core.Repository.Quality
public string Name { get; set; }
[Ignore]
[SubSonicIgnore]
[DisplayName("Allowed Qualities")]
public List<QualityTypes> Allowed { get; set; }
[Ignore]
[SubSonicIgnore]
[DisplayName("Allowed Qualities String")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public string AllowedString { get; set; }
@ -60,7 +57,7 @@ namespace NzbDrone.Core.Repository.Quality
}
[Ignore]
[SubSonicToManyRelation]
public virtual List<Series> Series { get; private set; }
}
}

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PetaPoco;
using PetaPoco;
namespace NzbDrone.Core.Repository
{

@ -3,35 +3,34 @@ using System.Collections.Generic;
using System.ComponentModel;
using NzbDrone.Core.Repository.Quality;
using PetaPoco;
using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Repository
{
[PrimaryKey("SeriesId", autoIncrement = false)]
public class Series
{
[SubSonicPrimaryKey(false)]
public virtual int SeriesId { get; set; }
[SubSonicNullString]
public string Title { get; set; }
[SubSonicNullString]
public string CleanTitle { get; set; }
[SubSonicNullString]
public string Status { get; set; }
[SubSonicNullString]
public string Overview { get; set; }
[DisplayName("Air on")]
public DayOfWeek? AirsDayOfWeek { get; set; }
[SubSonicNullString]
public String AirTimes { get; set; }
[SubSonicNullString]
public string Language { get; set; }
public string Path { get; set; }
@ -56,15 +55,12 @@ namespace NzbDrone.Core.Repository
public DateTime? LastDiskSync { get; set; }
[SubSonicToOneRelation(ThisClassContainsJoinKey = true, JoinKeyName = "QualityProfileId")]
[Ignore]
public virtual QualityProfile QualityProfile { get; set; }
[SubSonicToManyRelation]
[Ignore]
public virtual IList<Episode> Episodes { get; set; }
[SubSonicToManyRelation]
[Ignore]
public virtual IList<EpisodeFile> EpisodeFiles { get; protected set; }
}

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Caching;
using NLog;

@ -71,10 +71,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libraries\NLog.dll</HintPath>
</Reference>
<Reference Include="SubSonic.Core, Version=3.0.0.3, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libraries\SubSonic.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />

Loading…
Cancel
Save