mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-10-30 15:32:31 +01:00
fixed some broken tests. broke some new ones.
This commit is contained in:
parent
57120c9eeb
commit
0a3b0c9973
@ -63,7 +63,6 @@ namespace NzbDrone.Core.Test.Configuration
|
||||
|
||||
Db.Insert(new Config { Key = key, Value = originalValue });
|
||||
|
||||
//Act
|
||||
Subject.SetValue(key, newValue);
|
||||
var result = Subject.GetValue(key, "");
|
||||
|
||||
|
@ -112,5 +112,25 @@ namespace NzbDrone.Core.Test.Datastore
|
||||
var loadedQuality = Db.Single<History.History>().Quality;
|
||||
loadedQuality.Should().Be(quality);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void embedded_list_of_document_with_json()
|
||||
{
|
||||
var quality = new QualityModel { Quality = Quality.Bluray720p, Proper = true };
|
||||
|
||||
var history = Builder<History.History>.CreateListOfSize(2)
|
||||
.All().With(c => c.Id = 0)
|
||||
.Build().ToList();
|
||||
|
||||
history[0].Quality = new QualityModel(Quality.HDTV1080p, true);
|
||||
history[1].Quality = new QualityModel(Quality.Bluray720p, true);
|
||||
|
||||
|
||||
Db.InsertMany(history);
|
||||
|
||||
var returnedHistory = Db.All<History.History>();
|
||||
|
||||
returnedHistory[0].Quality.Quality.Should().Be(Quality.HDTV1080p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,16 +18,15 @@ using NzbDrone.Core.Test.Framework;
|
||||
namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
[TestFixture]
|
||||
// ReSharper disable InconsistentNaming
|
||||
public class UpgradeHistorySpecificationFixture : CoreTest
|
||||
{
|
||||
private UpgradeHistorySpecification _upgradeHistory;
|
||||
|
||||
private EpisodeParseResult parseResultMulti;
|
||||
private EpisodeParseResult parseResultSingle;
|
||||
private QualityModel firstQuality;
|
||||
private QualityModel secondQuality;
|
||||
private Series fakeSeries;
|
||||
private EpisodeParseResult _parseResultMulti;
|
||||
private EpisodeParseResult _parseResultSingle;
|
||||
private QualityModel _upgradableQuality;
|
||||
private QualityModel _notupgradableQuality;
|
||||
private Series _fakeSeries;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
@ -35,51 +34,53 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
Mocker.Resolve<QualityUpgradableSpecification>();
|
||||
_upgradeHistory = Mocker.Resolve<UpgradeHistorySpecification>();
|
||||
|
||||
var singleEpisodeList = new List<Episode> { new Episode { SeasonNumber = 12, EpisodeNumber = 3 } };
|
||||
var singleEpisodeList = new List<Episode> { new Episode { Id = 1, SeasonNumber = 12, EpisodeNumber = 3 } };
|
||||
var doubleEpisodeList = new List<Episode> {
|
||||
new Episode { SeasonNumber = 12, EpisodeNumber = 3 },
|
||||
new Episode { SeasonNumber = 12, EpisodeNumber = 4 },
|
||||
new Episode { SeasonNumber = 12, EpisodeNumber = 5 }
|
||||
new Episode {Id = 1, SeasonNumber = 12, EpisodeNumber = 3 },
|
||||
new Episode {Id = 2, SeasonNumber = 12, EpisodeNumber = 4 },
|
||||
new Episode {Id = 3, SeasonNumber = 12, EpisodeNumber = 5 }
|
||||
};
|
||||
|
||||
fakeSeries = Builder<Series>.CreateNew()
|
||||
_fakeSeries = Builder<Series>.CreateNew()
|
||||
.With(c => c.QualityProfile = new QualityProfile { Cutoff = Quality.Bluray1080p })
|
||||
.Build();
|
||||
|
||||
parseResultMulti = new EpisodeParseResult
|
||||
_parseResultMulti = new EpisodeParseResult
|
||||
{
|
||||
Series = fakeSeries,
|
||||
Series = _fakeSeries,
|
||||
Quality = new QualityModel(Quality.DVD, true),
|
||||
EpisodeNumbers = new List<int> { 3, 4 },
|
||||
SeasonNumber = 12,
|
||||
Episodes = doubleEpisodeList
|
||||
};
|
||||
|
||||
parseResultSingle = new EpisodeParseResult
|
||||
_parseResultSingle = new EpisodeParseResult
|
||||
{
|
||||
Series = fakeSeries,
|
||||
Series = _fakeSeries,
|
||||
Quality = new QualityModel(Quality.DVD, true),
|
||||
EpisodeNumbers = new List<int> { 3 },
|
||||
SeasonNumber = 12,
|
||||
Episodes = singleEpisodeList
|
||||
};
|
||||
|
||||
firstQuality = new QualityModel(Quality.Bluray1080p, true);
|
||||
secondQuality = new QualityModel(Quality.Bluray1080p, true);
|
||||
_upgradableQuality = new QualityModel(Quality.SDTV, false);
|
||||
_notupgradableQuality = new QualityModel(Quality.HDTV1080p, true);
|
||||
|
||||
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(1)).Returns(firstQuality);
|
||||
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(2)).Returns(secondQuality);
|
||||
|
||||
|
||||
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(1)).Returns(_notupgradableQuality);
|
||||
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(2)).Returns(_notupgradableQuality);
|
||||
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(3)).Returns<QualityModel>(null);
|
||||
}
|
||||
|
||||
private void WithFirstReportUpgradable()
|
||||
{
|
||||
firstQuality.Quality = Quality.SDTV;
|
||||
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(1)).Returns(_upgradableQuality);
|
||||
}
|
||||
|
||||
private void WithSecondReportUpgradable()
|
||||
{
|
||||
secondQuality.Quality = Quality.SDTV;
|
||||
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(2)).Returns(_upgradableQuality);
|
||||
}
|
||||
|
||||
|
||||
@ -87,7 +88,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
public void should_be_upgradable_if_only_episode_is_upgradable()
|
||||
{
|
||||
WithFirstReportUpgradable();
|
||||
_upgradeHistory.IsSatisfiedBy(parseResultSingle).Should().BeTrue();
|
||||
_upgradeHistory.IsSatisfiedBy(_parseResultSingle).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -95,39 +96,39 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||
{
|
||||
WithFirstReportUpgradable();
|
||||
WithSecondReportUpgradable();
|
||||
_upgradeHistory.IsSatisfiedBy(parseResultMulti).Should().BeTrue();
|
||||
_upgradeHistory.IsSatisfiedBy(_parseResultMulti).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_be_upgradable_if_both_episodes_are_not_upgradable()
|
||||
{
|
||||
_upgradeHistory.IsSatisfiedBy(parseResultMulti).Should().BeFalse();
|
||||
_upgradeHistory.IsSatisfiedBy(_parseResultMulti).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_not_upgradable_if_only_first_episodes_is_upgradable()
|
||||
{
|
||||
WithFirstReportUpgradable();
|
||||
_upgradeHistory.IsSatisfiedBy(parseResultMulti).Should().BeFalse();
|
||||
_upgradeHistory.IsSatisfiedBy(_parseResultMulti).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_be_not_upgradable_if_only_second_episodes_is_upgradable()
|
||||
{
|
||||
WithSecondReportUpgradable();
|
||||
_upgradeHistory.IsSatisfiedBy(parseResultMulti).Should().BeFalse();
|
||||
_upgradeHistory.IsSatisfiedBy(_parseResultMulti).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_be_upgradable_if_episode_is_of_same_quality_as_existing()
|
||||
{
|
||||
fakeSeries.QualityProfile = new QualityProfile { Cutoff = Quality.WEBDL1080p };
|
||||
parseResultSingle.Quality = new QualityModel(Quality.WEBDL1080p, false);
|
||||
firstQuality = new QualityModel(Quality.WEBDL1080p, false);
|
||||
_fakeSeries.QualityProfile = new QualityProfile { Cutoff = Quality.WEBDL1080p };
|
||||
_parseResultSingle.Quality = new QualityModel(Quality.WEBDL1080p, false);
|
||||
_upgradableQuality = new QualityModel(Quality.WEBDL1080p, false);
|
||||
|
||||
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(1)).Returns(firstQuality);
|
||||
Mocker.GetMock<IHistoryService>().Setup(c => c.GetBestQualityInHistory(1)).Returns(_upgradableQuality);
|
||||
|
||||
_upgradeHistory.IsSatisfiedBy(parseResultSingle).Should().BeFalse();
|
||||
_upgradeHistory.IsSatisfiedBy(_parseResultSingle).Should().BeFalse();
|
||||
}
|
||||
}
|
||||
}
|
@ -123,7 +123,7 @@ namespace NzbDrone.Core.Test.Framework
|
||||
{
|
||||
void InsertMany<T>(IEnumerable<T> items) where T : ModelBase, new();
|
||||
void Insert<T>(T item) where T : ModelBase, new();
|
||||
IEnumerable<T> All<T>() where T : ModelBase, new();
|
||||
List<T> All<T>() where T : ModelBase, new();
|
||||
T Single<T>() where T : ModelBase, new();
|
||||
void Update<T>(T childModel) where T : ModelBase, new();
|
||||
void Delete<T>(T childModel) where T : ModelBase, new();
|
||||
@ -148,9 +148,9 @@ namespace NzbDrone.Core.Test.Framework
|
||||
new BasicRepository<T>(_dbConnection).Insert(item);
|
||||
}
|
||||
|
||||
public IEnumerable<T> All<T>() where T : ModelBase, new()
|
||||
public List<T> All<T>() where T : ModelBase, new()
|
||||
{
|
||||
return new BasicRepository<T>(_dbConnection).All();
|
||||
return new BasicRepository<T>(_dbConnection).All().ToList();
|
||||
}
|
||||
|
||||
public T Single<T>() where T : ModelBase, new()
|
||||
|
@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.History;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using NzbDrone.Core.Tv;
|
||||
@ -12,7 +10,7 @@ using NzbDrone.Core.Test.Framework;
|
||||
namespace NzbDrone.Core.Test.HistoryTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class HistoryServiceTest : DbTest<HistoryRepository, History.History>
|
||||
public class HistoryRepositoryFixture : DbTest<HistoryRepository, History.History>
|
||||
{
|
||||
[Test]
|
||||
public void Trim_Items()
|
@ -242,7 +242,7 @@
|
||||
<Compile Include="TvTests\QualityModelFixture.cs" />
|
||||
<Compile Include="RootFolderTests\RootFolderServiceFixture.cs" />
|
||||
<Compile Include="Indexers\IndexerServiceTest.cs" />
|
||||
<Compile Include="HistoryTests\HistoryServiceTest.cs" />
|
||||
<Compile Include="HistoryTests\HistoryRepositoryFixture.cs" />
|
||||
<Compile Include="MediaFileTests\MediaFileServiceTest.cs" />
|
||||
<Compile Include="Configuration\ConfigServiceFixture.cs" />
|
||||
<Compile Include="TvTests\EpisodeProviderTests\EpisodeProviderTest.cs" />
|
||||
@ -301,6 +301,9 @@
|
||||
<Content Include="Files\JsonError.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="SQLite.Interop.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Include="Files\RSS\nzbx_search.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
BIN
NzbDrone.Core.Test/SQLite.Interop.dll
Normal file
BIN
NzbDrone.Core.Test/SQLite.Interop.dll
Normal file
Binary file not shown.
@ -4,7 +4,14 @@ namespace NzbDrone.Core.Configuration
|
||||
{
|
||||
public class Config : ModelBase
|
||||
{
|
||||
public string Key { get; set; }
|
||||
private string _key;
|
||||
|
||||
public string Key
|
||||
{
|
||||
get { return _key; }
|
||||
set { _key = value.ToLowerInvariant(); }
|
||||
}
|
||||
|
||||
public string Value { get; set; }
|
||||
}
|
||||
}
|
@ -34,10 +34,10 @@ namespace NzbDrone.Core.Configuration
|
||||
var type = GetType();
|
||||
var properties = type.GetProperties();
|
||||
|
||||
foreach(var propertyInfo in properties)
|
||||
foreach (var propertyInfo in properties)
|
||||
{
|
||||
var value = propertyInfo.GetValue(this, null);
|
||||
|
||||
|
||||
dict.Add(propertyInfo.Name, value);
|
||||
}
|
||||
|
||||
@ -268,7 +268,7 @@ namespace NzbDrone.Core.Configuration
|
||||
get { return GetValue("TwitterAccessTokenSecret", String.Empty); }
|
||||
set { SetValue("TwitterAccessTokenSecret", value); }
|
||||
}
|
||||
|
||||
|
||||
public string GrowlHost
|
||||
{
|
||||
get { return GetValue("GrowlHost", "localhost:23053"); }
|
||||
@ -280,7 +280,7 @@ namespace NzbDrone.Core.Configuration
|
||||
get { return GetValue("GrowlPassword", String.Empty); }
|
||||
set { SetValue("GrowlPassword", value); }
|
||||
}
|
||||
|
||||
|
||||
public string ProwlApiKeys
|
||||
{
|
||||
get { return GetValue("ProwlApiKeys", String.Empty); }
|
||||
@ -552,7 +552,7 @@ namespace NzbDrone.Core.Configuration
|
||||
{
|
||||
var allWithDefaults = AllWithDefaults();
|
||||
|
||||
foreach(var configValue in configValues)
|
||||
foreach (var configValue in configValues)
|
||||
{
|
||||
object currentValue;
|
||||
allWithDefaults.TryGetValue(configValue.Key, out currentValue);
|
||||
@ -571,7 +571,7 @@ namespace NzbDrone.Core.Configuration
|
||||
{
|
||||
if (!_cache.Any())
|
||||
{
|
||||
_cache = All().ToDictionary(c => c.Key, c => c.Value);
|
||||
_cache = All().ToDictionary(c => c.Key.ToLower(), c => c.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -150,6 +150,8 @@ namespace NzbDrone.Core.Datastore
|
||||
throw new InvalidOperationException("Attempted to updated model without ID");
|
||||
}
|
||||
|
||||
_dataMapper.Update<TModel>(model, m => m.Id == model.Id);
|
||||
|
||||
// _database.UpdateOnly(model, onlyFields, m => m.Id == model.Id);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user