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