mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 12:02:35 +02:00
fixed unit test file path generation to be linux compatible.
This commit is contained in:
parent
4ac2997d78
commit
b73485a58b
@ -184,7 +184,7 @@ public void MaxOrDefault_should_return_zero_when_collection_is_empty()
|
||||
public void MaxOrDefault_should_return_max_when_collection_is_not_empty()
|
||||
{
|
||||
//Setup
|
||||
var list = new List<int> {6, 4, 5, 3, 8, 10};
|
||||
var list = new List<int> { 6, 4, 5, 3, 8, 10 };
|
||||
|
||||
//Act
|
||||
var result = list.MaxOrDefault();
|
||||
@ -210,13 +210,13 @@ public void MaxOrDefault_should_return_zero_when_collection_is_null()
|
||||
public void Truncate_should_truncate_strings_to_max_specified_number_of_bytes()
|
||||
{
|
||||
//Setup
|
||||
var str = File.ReadAllText(@"Files\LongOverview.txt");
|
||||
var str = ReadAllText("Files", "LongOverview.txt");
|
||||
|
||||
//Act
|
||||
var resultString = str.Truncate(1000);
|
||||
|
||||
//Resolve
|
||||
var result = new UTF8Encoding().GetBytes(resultString);
|
||||
var result = new UTF8Encoding().GetBytes(resultString);
|
||||
result.Length.Should().BeLessOrEqualTo(1000);
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,11 @@ protected FileStream OpenRead(params string[] path)
|
||||
{
|
||||
return File.OpenRead(Path.Combine(path));
|
||||
}
|
||||
|
||||
protected string ReadAllText(params string[] path)
|
||||
{
|
||||
return ReadAllText(Path.Combine(path));
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class CoreTest<TSubject> : CoreTest where TSubject : class
|
||||
|
@ -29,7 +29,7 @@ public void should_get_size_when_parsing_recent_feed()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(h => h.DownloadString("https://nzbx.co/api/recent?category=tv", It.IsAny<NetworkCredential>()))
|
||||
.Returns(File.ReadAllText(".\\Files\\Rss\\SizeParsing\\nzbx_recent.json"));
|
||||
.Returns(ReadAllText("Files", "Rss", "SizeParsing", "nzbx_recent.json"));
|
||||
|
||||
//Act
|
||||
var parseResults = Mocker.Resolve<Nzbx>().FetchRss();
|
||||
@ -38,12 +38,12 @@ public void should_get_size_when_parsing_recent_feed()
|
||||
parseResults[0].Size.Should().Be(890190951);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Test]
|
||||
public void should_get_size_when_parsing_search_results()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(h => h.DownloadString("https://nzbx.co/api/search?q=30+Rock+S01E01", It.IsAny<NetworkCredential>()))
|
||||
.Returns(File.ReadAllText(".\\Files\\Rss\\SizeParsing\\nzbx_search.json"));
|
||||
.Returns(ReadAllText("Files", "Rss", "SizeParsing", "nzbx_search.json"));
|
||||
|
||||
//Act
|
||||
var parseResults = Mocker.Resolve<Nzbx>().FetchEpisode("30 Rock", 1, 1);
|
||||
@ -57,7 +57,7 @@ public void should_be_able_parse_results_from_recent_feed()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(h => h.DownloadString(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
||||
.Returns(File.ReadAllText(".\\Files\\Rss\\nzbx_recent.json"));
|
||||
.Returns(ReadAllText("Files", "Rss", "nzbx_recent.json"));
|
||||
|
||||
var parseResults = Mocker.Resolve<Nzbx>().FetchRss();
|
||||
|
||||
@ -69,18 +69,18 @@ public void should_be_able_parse_results_from_recent_feed()
|
||||
|
||||
[Test]
|
||||
public void should_be_able_to_parse_results_from_search_results()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(h => h.DownloadString(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
||||
.Returns(File.ReadAllText(".\\Files\\Rss\\nzbx_search.json"));
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(h => h.DownloadString(It.IsAny<String>(), It.IsAny<NetworkCredential>()))
|
||||
.Returns(ReadAllText("Files", "Rss", "nzbx_search.json"));
|
||||
|
||||
var parseResults = Mocker.Resolve<Nzbx>().FetchEpisode("30 Rock", 1, 1);
|
||||
var parseResults = Mocker.Resolve<Nzbx>().FetchEpisode("30 Rock", 1, 1);
|
||||
|
||||
parseResults.Should().NotBeEmpty();
|
||||
parseResults.Should().OnlyContain(s => s.Indexer == "nzbx");
|
||||
parseResults.Should().OnlyContain(s => !String.IsNullOrEmpty(s.OriginalString));
|
||||
parseResults.Should().OnlyContain(s => s.Age >= 0);
|
||||
}
|
||||
parseResults.Should().NotBeEmpty();
|
||||
parseResults.Should().OnlyContain(s => s.Indexer == "nzbx");
|
||||
parseResults.Should().OnlyContain(s => !String.IsNullOrEmpty(s.OriginalString));
|
||||
parseResults.Should().OnlyContain(s => s.Age >= 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_get_postedDate_when_parsing_recent_feed()
|
||||
@ -89,7 +89,7 @@ public void should_get_postedDate_when_parsing_recent_feed()
|
||||
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(h => h.DownloadString("https://nzbx.co/api/recent?category=tv", It.IsAny<NetworkCredential>()))
|
||||
.Returns(File.ReadAllText(".\\Files\\Rss\\SizeParsing\\nzbx_recent.json"));
|
||||
.Returns(ReadAllText("Files", "Rss", "SizeParsing", "nzbx_recent.json"));
|
||||
|
||||
//Act
|
||||
var parseResults = Mocker.Resolve<Nzbx>().FetchRss();
|
||||
@ -105,7 +105,7 @@ public void should_get_postedDate_when_parsing_search_results()
|
||||
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(h => h.DownloadString("https://nzbx.co/api/search?q=30+Rock+S01E01", It.IsAny<NetworkCredential>()))
|
||||
.Returns(File.ReadAllText(".\\Files\\Rss\\SizeParsing\\nzbx_search.json"));
|
||||
.Returns(ReadAllText("Files", "Rss", "SizeParsing", "nzbx_search.json"));
|
||||
|
||||
//Act
|
||||
var parseResults = Mocker.Resolve<Nzbx>().FetchEpisode("30 Rock", 1, 1);
|
||||
@ -119,7 +119,7 @@ public void should_name_nzb_properly()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(h => h.DownloadString("https://nzbx.co/api/recent?category=tv", It.IsAny<NetworkCredential>()))
|
||||
.Returns(File.ReadAllText(".\\Files\\Rss\\SizeParsing\\nzbx_recent.json"));
|
||||
.Returns(ReadAllText("Files", "Rss", "SizeParsing", "nzbx_recent.json"));
|
||||
|
||||
//Act
|
||||
var parseResults = Mocker.Resolve<Nzbx>().FetchRss();
|
||||
|
@ -10,11 +10,12 @@
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Download.Clients;
|
||||
using NzbDrone.Core.Download.Clients.Nzbget;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.NzbgetProviderTests
|
||||
{
|
||||
public class DownloadNzbFixture : TestBase
|
||||
public class DownloadNzbFixture : CoreTest
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
@ -29,12 +30,12 @@ public void Setup()
|
||||
fakeConfig.SetupGet(c => c.NzbgetRecentTvPriority).Returns(PriorityType.High);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void WithFailResponse()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.PostCommand("192.168.5.55:6789", "nzbget", "pass", It.IsAny<String>()))
|
||||
.Returns(File.ReadAllText(@".\Files\Nzbget\JsonError.txt"));
|
||||
.Returns(ReadAllText("Files", "Nzbget", "JsonError.txt"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -10,11 +10,12 @@
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.Download.Clients;
|
||||
using NzbDrone.Core.Download.Clients.Nzbget;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.DownloadClientTests.NzbgetProviderTests
|
||||
{
|
||||
public class QueueFixture : TestBase
|
||||
public class QueueFixture : CoreTest
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
@ -33,21 +34,21 @@ private void WithFullQueue()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.PostCommand("192.168.5.55:6789", "nzbget", "pass", It.IsAny<String>()))
|
||||
.Returns(File.ReadAllText(@".\Files\Nzbget\Queue.txt"));
|
||||
.Returns(ReadAllText("Files", "Nzbget", "Queue.txt"));
|
||||
}
|
||||
|
||||
private void WithEmptyQueue()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.PostCommand("192.168.5.55:6789", "nzbget", "pass", It.IsAny<String>()))
|
||||
.Returns(File.ReadAllText(@".\Files\Nzbget\Queue_empty.txt"));
|
||||
.Returns(ReadAllText("Files", "Nzbget", "Queue_empty.txt"));
|
||||
}
|
||||
|
||||
private void WithFailResponse()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.PostCommand("192.168.5.55:6789", "nzbget", "pass", It.IsAny<String>()))
|
||||
.Returns(File.ReadAllText(@".\Files\Nzbget\JsonError.txt"));
|
||||
.Returns(ReadAllText("Files", "Nzbget", "JsonError.txt"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -51,23 +51,20 @@ private void WithFullQueue()
|
||||
s =>
|
||||
s.DownloadString(
|
||||
"http://192.168.5.55:2222/api?mode=queue&output=json&start=0&limit=0&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
|
||||
.Returns(File.ReadAllText(@".\Files\Queue.txt"));
|
||||
.Returns(ReadAllText("Files","Queue.txt"));
|
||||
}
|
||||
|
||||
private void WithEmptyQueue()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(
|
||||
s =>
|
||||
s.DownloadString(
|
||||
"http://192.168.5.55:2222/api?mode=queue&output=json&start=0&limit=0&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
|
||||
.Returns(File.ReadAllText(@".\Files\QueueEmpty.txt"));
|
||||
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=queue&output=json&start=0&limit=0&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
|
||||
.Returns(ReadAllText("Files","QueueEmpty.txt"));
|
||||
}
|
||||
|
||||
private void WithFailResponse()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadString(It.IsAny<String>())).Returns(File.ReadAllText(@".\Files\JsonError.txt"));
|
||||
.Setup(s => s.DownloadString(It.IsAny<String>())).Returns(ReadAllText("Files","JsonError.txt"));
|
||||
}
|
||||
|
||||
private void WithUnknownPriorityQueue()
|
||||
@ -77,7 +74,7 @@ private void WithUnknownPriorityQueue()
|
||||
s =>
|
||||
s.DownloadString(
|
||||
"http://192.168.5.55:2222/api?mode=queue&output=json&start=0&limit=0&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
|
||||
.Returns(File.ReadAllText(@".\Files\QueueUnknownPriority.txt"));
|
||||
.Returns(ReadAllText("Files", "QueueUnknownPriority.txt"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -81,7 +81,7 @@ public void should_be_able_to_get_categories_when_config_is_passed_in()
|
||||
|
||||
Mocker.GetMock<HttpProvider>(MockBehavior.Strict)
|
||||
.Setup(s => s.DownloadString("http://192.168.5.22:1111/api?mode=get_cats&output=json&apikey=5c770e3197e4fe763423ee7c392c25d2&ma_username=admin2&ma_password=pass2"))
|
||||
.Returns(File.ReadAllText(@".\Files\Categories_json.txt"));
|
||||
.Returns(ReadAllText("Files","Categories_json.txt"));
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SabProvider>().GetCategories(host, port, apikey, username, password);
|
||||
@ -96,7 +96,7 @@ public void should_be_able_to_get_categories_using_config()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>(MockBehavior.Strict)
|
||||
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=get_cats&output=json&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
|
||||
.Returns(File.ReadAllText(@".\Files\Categories_json.txt"));
|
||||
.Returns(ReadAllText("Files","Categories_json.txt"));
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SabProvider>().GetCategories();
|
||||
@ -111,7 +111,7 @@ public void GetHistory_should_return_a_list_with_items_when_the_history_has_item
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=history&output=json&start=0&limit=0&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
|
||||
.Returns(File.ReadAllText(@".\Files\History.txt"));
|
||||
.Returns(ReadAllText("Files", "History.txt"));
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SabProvider>().GetHistory();
|
||||
@ -125,7 +125,7 @@ public void GetHistory_should_return_an_empty_list_when_the_queue_is_empty()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=history&output=json&start=0&limit=0&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
|
||||
.Returns(File.ReadAllText(@".\Files\HistoryEmpty.txt"));
|
||||
.Returns(ReadAllText("Files","HistoryEmpty.txt"));
|
||||
|
||||
//Act
|
||||
var result = Mocker.Resolve<SabProvider>().GetHistory();
|
||||
@ -139,7 +139,7 @@ public void GetHistory_should_return_an_empty_list_when_there_is_an_error_gettin
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadString("http://192.168.5.55:2222/api?mode=history&output=json&start=0&limit=0&apikey=5c770e3197e4fe763423ee7c392c25d1&ma_username=admin&ma_password=pass"))
|
||||
.Returns(File.ReadAllText(@".\Files\JsonError.txt"));
|
||||
.Returns(ReadAllText("Files","JsonError.txt"));
|
||||
|
||||
//Act
|
||||
Assert.Throws<ApplicationException>(() => Mocker.Resolve<SabProvider>().GetHistory(), "API Key Incorrect");
|
||||
|
@ -32,7 +32,7 @@ private void WithValidJson()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>()
|
||||
.Setup(s => s.DownloadString(SceneMappingUrl))
|
||||
.Returns(File.ReadAllText(@".\Files\SceneMappings.json"));
|
||||
.Returns(ReadAllText("Files", "SceneMappings.json"));
|
||||
}
|
||||
|
||||
private void WithErrorDownloadingJson()
|
||||
|
@ -23,19 +23,19 @@ public class GetSceneTvdbMappingsFixture : CoreTest
|
||||
private void WithFailureJson()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
|
||||
.Returns(File.ReadAllText(@".\Files\Xem\Failure.txt"));
|
||||
.Returns(ReadAllText("Files","Xem","Failure.txt"));
|
||||
}
|
||||
|
||||
private void WithIdsJson()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
|
||||
.Returns(File.ReadAllText(@".\Files\Xem\Ids.txt"));
|
||||
.Returns(ReadAllText("Files","Xem","Ids.txt"));
|
||||
}
|
||||
|
||||
private void WithMappingsJson()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
|
||||
.Returns(File.ReadAllText(@".\Files\Xem\Mappings.txt"));
|
||||
.Returns(ReadAllText("Files","Xem","Mappings.txt"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -23,19 +23,19 @@ public class GetXemSeriesIdsFixture : CoreTest
|
||||
private void WithFailureJson()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
|
||||
.Returns(File.ReadAllText(@".\Files\Xem\Failure.txt"));
|
||||
.Returns(ReadAllText("Files", "Xem", "Failure.txt"));
|
||||
}
|
||||
|
||||
private void WithIdsJson()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
|
||||
.Returns(File.ReadAllText(@".\Files\Xem\Ids.txt"));
|
||||
.Returns(ReadAllText("Files", "Xem", "Ids.txt"));
|
||||
}
|
||||
|
||||
private void WithMappingsJson()
|
||||
{
|
||||
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString(It.IsAny<String>()))
|
||||
.Returns(File.ReadAllText(@".\Files\Xem\Mappings.txt"));
|
||||
.Returns(ReadAllText("Files", "Xem", "Mappings.txt"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
Loading…
Reference in New Issue
Block a user