mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-22 22:14:44 -04:00
Fixed: Handling of unknown status types in DownloadStation
This commit is contained in:
+49
@@ -0,0 +1,49 @@
|
||||
using FluentAssertions;
|
||||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Download.Clients.DownloadStation;
|
||||
|
||||
namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class DownloadStationsTaskStatusJsonConverterFixture
|
||||
{
|
||||
[TestCase("captcha_needed", DownloadStationTaskStatus.CaptchaNeeded)]
|
||||
[TestCase("filehosting_waiting", DownloadStationTaskStatus.FilehostingWaiting)]
|
||||
[TestCase("hash_checking", DownloadStationTaskStatus.HashChecking)]
|
||||
[TestCase("error", DownloadStationTaskStatus.Error)]
|
||||
[TestCase("downloading", DownloadStationTaskStatus.Downloading)]
|
||||
public void should_parse_enum_correctly(string value, DownloadStationTaskStatus expected)
|
||||
{
|
||||
var task = "{\"Status\": \"" + value + "\"}";
|
||||
|
||||
var item = JsonConvert.DeserializeObject<DownloadStationTask>(task);
|
||||
|
||||
item.Status.Should().Be(expected);
|
||||
}
|
||||
|
||||
[TestCase("captcha_needed", DownloadStationTaskStatus.CaptchaNeeded)]
|
||||
[TestCase("filehosting_waiting", DownloadStationTaskStatus.FilehostingWaiting)]
|
||||
[TestCase("hash_checking", DownloadStationTaskStatus.HashChecking)]
|
||||
[TestCase("error", DownloadStationTaskStatus.Error)]
|
||||
[TestCase("downloading", DownloadStationTaskStatus.Downloading)]
|
||||
public void should_serialize_enum_correctly(string expected, DownloadStationTaskStatus value)
|
||||
{
|
||||
var task = new DownloadStationTask { Status = value };
|
||||
|
||||
var item = JsonConvert.SerializeObject(task);
|
||||
|
||||
item.Should().Contain(expected);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_unknown_if_unknown_enum_value()
|
||||
{
|
||||
var task = "{\"Status\": \"some_unknown_value\"}";
|
||||
|
||||
var item = JsonConvert.DeserializeObject<DownloadStationTask>(task);
|
||||
|
||||
item.Status.Should().Be(DownloadStationTaskStatus.Unknown);
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
@@ -604,9 +604,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
[TestCase(DownloadStationTaskStatus.Finished, DownloadItemStatus.Completed)]
|
||||
[TestCase(DownloadStationTaskStatus.Finishing, DownloadItemStatus.Downloading)]
|
||||
[TestCase(DownloadStationTaskStatus.HashChecking, DownloadItemStatus.Downloading)]
|
||||
[TestCase(DownloadStationTaskStatus.CaptchaNeeded, DownloadItemStatus.Downloading)]
|
||||
[TestCase(DownloadStationTaskStatus.Paused, DownloadItemStatus.Paused)]
|
||||
[TestCase(DownloadStationTaskStatus.Seeding, DownloadItemStatus.Completed)]
|
||||
[TestCase(DownloadStationTaskStatus.FilehostingWaiting, DownloadItemStatus.Queued)]
|
||||
[TestCase(DownloadStationTaskStatus.Waiting, DownloadItemStatus.Queued)]
|
||||
[TestCase(DownloadStationTaskStatus.Unknown, DownloadItemStatus.Queued)]
|
||||
public void GetItems_should_return_item_as_downloadItemStatus(DownloadStationTaskStatus apiStatus, DownloadItemStatus expectedItemStatus)
|
||||
{
|
||||
GivenSerialNumber();
|
||||
|
||||
+4
@@ -414,8 +414,12 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
|
||||
[TestCase(DownloadStationTaskStatus.Finished, DownloadItemStatus.Completed)]
|
||||
[TestCase(DownloadStationTaskStatus.Finishing, DownloadItemStatus.Downloading)]
|
||||
[TestCase(DownloadStationTaskStatus.HashChecking, DownloadItemStatus.Downloading)]
|
||||
[TestCase(DownloadStationTaskStatus.CaptchaNeeded, DownloadItemStatus.Downloading)]
|
||||
[TestCase(DownloadStationTaskStatus.Paused, DownloadItemStatus.Paused)]
|
||||
[TestCase(DownloadStationTaskStatus.Seeding, DownloadItemStatus.Completed)]
|
||||
[TestCase(DownloadStationTaskStatus.FilehostingWaiting, DownloadItemStatus.Queued)]
|
||||
[TestCase(DownloadStationTaskStatus.Waiting, DownloadItemStatus.Queued)]
|
||||
[TestCase(DownloadStationTaskStatus.Unknown, DownloadItemStatus.Queued)]
|
||||
public void GetItems_should_return_item_as_downloadItemStatus(DownloadStationTaskStatus apiStatus, DownloadItemStatus expectedItemStatus)
|
||||
{
|
||||
GivenSerialNumber();
|
||||
|
||||
@@ -147,6 +147,7 @@
|
||||
<Compile Include="Download\DownloadClientTests\Blackhole\UsenetBlackholeFixture.cs" />
|
||||
<Compile Include="Download\DownloadClientTests\DelugeTests\DelugeFixture.cs" />
|
||||
<Compile Include="Download\DownloadClientTests\DownloadClientFixtureBase.cs" />
|
||||
<Compile Include="Download\DownloadClientTests\DownloadStationTests\DownloadStationsTaskStatusJsonConverterFixture.cs" />
|
||||
<Compile Include="Download\DownloadClientTests\DownloadStationTests\TorrentDownloadStationFixture.cs" />
|
||||
<Compile Include="Download\DownloadClientTests\DownloadStationTests\SerialNumberProviderFixture.cs" />
|
||||
<Compile Include="Download\DownloadClientTests\DownloadStationTests\SharedFolderResolverFixture.cs" />
|
||||
|
||||
Reference in New Issue
Block a user