Updated subsonic to latest nightly build

Added foreign relations to all entities object
Removed unnecessary libraries
pull/4/head
Keivan 14 years ago
parent 899e5a9a22
commit beaf0cf939

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Moq;
@ -22,14 +23,10 @@ namespace NzbDrone.Core.Test
public static IRepository EmptyRepository
public static IRepository GetEmptyRepository()
{
get
{
var provider = ProviderFactory.GetProvider("Data Source=" + Guid.NewGuid() + ".testdb;Version=3;New=True", "System.Data.SQLite");
return new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations);
}
var provider = ProviderFactory.GetProvider("Data Source=" + Guid.NewGuid() + ".testdb;Version=3;New=True", "System.Data.SQLite");
return new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations);
}
public static IConfigProvider StandardConfig

@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.IO;
using MbUnit.Framework;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Core.Test
{
@ -18,11 +19,11 @@ namespace NzbDrone.Core.Test
{
//Arrange
var repo = MockLib.EmptyRepository;
var repo = MockLib.GetEmptyRepository();
var testProfile = new QualityProfile
{
Cutoff = Quality.SDTV,
Allowed = new List<Quality>() { Quality.HDTV, Quality.DVD },
Cutoff = QualityTypes.SDTV,
Allowed = new List<QualityTypes>() { QualityTypes.HDTV, QualityTypes.DVD },
};
//Act

@ -14,6 +14,7 @@ using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository;
using SubSonic.Repository;
using TvdbLib.Data;
using System.Linq;
// ReSharper disable InconsistentNaming
namespace NzbDrone.Core.Test
@ -34,10 +35,10 @@ namespace NzbDrone.Core.Test
//setup db to return a fake series
Series fakeSeries = Builder<Series>.CreateNew()
.With(f => f.TvdbId = tvDbId.ToString())
.With(f => f.TvdbId = tvDbId)
.Build();
moqData.Setup(f => f.Exists<Series>(c => c.TvdbId == tvDbId.ToString())).
moqData.Setup(f => f.Exists<Series>(c => c.TvdbId == tvDbId)).
Returns(true);
//setup tvdb to return the same show,
@ -66,5 +67,24 @@ namespace NzbDrone.Core.Test
//Verify that the show was added to the database only once.
moqData.Verify(c => c.Add(It.IsAny<Series>()), Times.Once());
}
[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([RandomNumbers(Minimum = 100, Maximum = 999, Count = 1)] int tvdbId)
{
//Arrange
var sonicRepo = MockLib.GetEmptyRepository();
var series = Builder<Series>.CreateNew().With(c => c.TvdbId = tvdbId).Build();
//Act
var addId = sonicRepo.Add(series);
//Assert
Assert.AreEqual(tvdbId, addId);
var allSeries = sonicRepo.All<Series>();
Assert.IsNotEmpty(allSeries);
Assert.AreEqual(tvdbId, allSeries.First().TvdbId);
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -121,10 +121,17 @@
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="Castle.Core, Version=2.5.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Libraries\Castle.Core.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL" />
<Reference Include="Ninject, Version=2.0.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL" />
<Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL" />
<Reference Include="SubSonic.Core, Version=3.0.0.3, Culture=neutral, processorArchitecture=MSIL" />
<Reference Include="SubSonic.Core, Version=3.0.1.3, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Libraries\SubSonic.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core" />
@ -146,13 +153,14 @@
<Compile Include="Providers\ISeriesProvider.cs" />
<Compile Include="Providers\ITvDbProvider.cs" />
<Compile Include="Providers\SabProvider.cs" />
<Compile Include="Repository\Quality\AllowedQuality.cs" />
<Compile Include="Repository\Config.cs" />
<Compile Include="Repository\QualityProfile.cs" />
<Compile Include="Repository\Quality\QualityProfile.cs" />
<Compile Include="Repository\Season.cs" />
<Compile Include="Repository\RemoteEpisode.cs" />
<Compile Include="Repository\LocalEpisode.cs" />
<Compile Include="Repository\Episode.cs" />
<Compile Include="Repository\Quality.cs" />
<Compile Include="Repository\Quality\QualityTypes.cs" />
<Compile Include="Repository\Series.cs" />
<Compile Include="Main.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@ -186,6 +194,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="Libraries\CassiniDev-lib.dll" />
<Content Include="Libraries\Castle.Core.dll" />
<Content Include="Libraries\log4net.dll" />
<Content Include="Libraries\log4net.xml" />
<Content Include="Libraries\Ninject.dll" />
@ -195,13 +204,9 @@
<Content Include="Libraries\NLog.dll" />
<Content Include="Libraries\NLog.pdb" />
<Content Include="Libraries\NLog.xml" />
<Content Include="Libraries\ObjectListView.dll" />
<Content Include="Libraries\RSS.NET.dll" />
<Content Include="Libraries\RSS.NET.XML" />
<Content Include="Libraries\SubSonic.Core.dll" />
<Content Include="Libraries\SubSonic.Core.XML" />
<Content Include="Libraries\System.Data.SQLite.dll" />
<Content Include="Libraries\System.Data.SQLite.Linq.dll" />
<Content Include="Libraries\System.Data.SQLite.XML" />
<Content Include="Libraries\TvdbLib.dll" />
<Content Include="Libraries\TvdbLib.pdb" />

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using SubSonic.Repository;
namespace NzbDrone.Core.Providers
@ -100,10 +101,10 @@ namespace NzbDrone.Core.Providers
foreach (var ep in result)
{
//TODO: Get TVDB episode Title, Series name and the rest of the details
ep.Season = Convert.ToInt32(match.Groups["seasonNumber"].Value);
ep.SeasonNumber = Convert.ToInt32(match.Groups["seasonNumber"].Value);
ep.Title = ReplaceSeparatorChars(match.Groups["episodeName"].Value);
ep.Proper = title.Contains("PROPER");
ep.Quality = Quality.Unknown;
ep.Quality = QualityTypes.Unknown;
}
return result;

@ -52,7 +52,7 @@ namespace NzbDrone.Core.Providers
public Series GetSeries(long tvdbId)
{
return _sonioRepo.Single<Series>(s => s.TvdbId == tvdbId.ToString());
return _sonioRepo.Single<Series>(s => s.TvdbId == tvdbId);
}
public IList<Season> GetSeasons(long tvdbId)
@ -60,7 +60,7 @@ namespace NzbDrone.Core.Providers
return _sonioRepo.Find<Season>(c => c.SeriesId == tvdbId);
}
public void SyncSeriesWithDisk()
{
foreach (string seriesFolder in _diskProvider.GetDirectories(_config.SeriesRoot))
@ -79,14 +79,14 @@ namespace NzbDrone.Core.Providers
private void AddShow(string path)
{
var searchResults = _tvDb.SearchSeries(new DirectoryInfo(path).Name);
if (searchResults.Count != 0 && !_sonioRepo.Exists<Series>(s => s.TvdbId == searchResults[0].Id.ToString()))
if (searchResults.Count != 0 && !_sonioRepo.Exists<Series>(s => s.TvdbId == searchResults[0].Id))
AddShow(path, _tvDb.GetSeries(searchResults[0].Id, searchResults[0].Language));
}
private void AddShow(string path, TvdbSeries series)
{
var repoSeries = new Series();
repoSeries.TvdbId = series.Id.ToString();
repoSeries.TvdbId = series.Id;
repoSeries.SeriesName = series.SeriesName;
repoSeries.AirTimes = series.AirsTime;
repoSeries.AirsDayOfWeek = series.AirsDayOfWeek;

@ -1,19 +1,27 @@
using System;
using System.ServiceModel.Syndication;
using NzbDrone.Core.Repository.Quality;
using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Repository
{
public class Episode
{
[SubSonicPrimaryKey]
public string EpisodeId { get; set; }
[SubSonicPrimaryKey(false)]
public long EpisodeId { get; set; }
public long SeriesId { get; set; }
public string Title { get; set; }
public long Season { get; set; }
public long SeasonId { get; set; }
public int SeasonNumber { get; set; }
public int EpisodeNumber { get; set; }
public DateTime AirDate { get; set; }
public Quality Quality { get; set; }
public QualityTypes Quality { get; set; }
public bool Proper { get; set; }
[SubSonicToOneRelation(ThisClassContainsJoinKey = true)]
public virtual Season Season { get; private set; }
[SubSonicToOneRelation(ThisClassContainsJoinKey = true)]
public virtual Series Series { get; private set; }
}
}

@ -0,0 +1,9 @@
namespace NzbDrone.Core.Repository.Quality
{
public class AllowedQuality
{
public int Id { get; set; }
public int ProfileId { get; set; }
public QualityTypes Quality { get; set; }
}
}

@ -1,16 +1,14 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Repository
namespace NzbDrone.Core.Repository.Quality
{
public class QualityProfile
{
public int Id { get; set; }
public Quality Cutoff { get; set; }
public QualityTypes Cutoff { get; set; }
[EditorBrowsable(EditorBrowsableState.Never)]
public string SonicAllowed
@ -27,15 +25,15 @@ namespace NzbDrone.Core.Repository
private set
{
var qualities = value.Split('|');
Allowed = new List<Quality>(qualities.Length);
Allowed = new List<QualityTypes>(qualities.Length);
foreach (var quality in qualities)
{
Allowed.Add((Quality)Convert.ToInt32(quality));
Allowed.Add((QualityTypes)Convert.ToInt32(quality));
}
}
}
[SubSonicIgnore]
public List<Quality> Allowed { get; set; }
public List<QualityTypes> Allowed { get; set; }
}
}

@ -1,10 +1,10 @@
namespace NzbDrone.Core.Repository
namespace NzbDrone.Core.Repository.Quality
{
// ReSharper disable InconsistentNaming
/// <summary>
/// Represents Video Quality
/// </summary>
public enum Quality
public enum QualityTypes
{
/// <summary>
/// Quality is unknown

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.ServiceModel.Syndication;
using SubSonic.SqlGeneration.Schema;
@ -6,11 +7,17 @@ namespace NzbDrone.Core.Repository
{
public class Season
{
[SubSonicPrimaryKey]
public string SeasonId { get; set; }
[SubSonicPrimaryKey(false)]
public long SeasonId { get; set; }
public long SeriesId { get; set; }
public int SeasonNumber { get; set; }
public bool Monitored { get; set; }
public string Folder { get; set; }
[SubSonicToManyRelation]
public virtual List<Episode> Episodes { get; set; }
[SubSonicToOneRelation(ThisClassContainsJoinKey = true)]
public virtual Series Series { get; set; }
}
}

@ -1,12 +1,13 @@
using System;
using System.Collections.Generic;
using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Repository
{
public class Series
{
[SubSonicPrimaryKey]
public string TvdbId { get; set; }
[SubSonicPrimaryKey(false)]
public int TvdbId { get; set; }
public string SeriesName { get; set; }
@ -22,5 +23,11 @@ namespace NzbDrone.Core.Repository
public string Language { get; set; }
public string Path { get; set; }
[SubSonicToManyRelation]
public virtual List<Season> Seasons { get; private set; }
[SubSonicToManyRelation]
public virtual List<Episode> Episodes { get; private set; }
}
}
Loading…
Cancel
Save