moved some of the helper classes to their proper location.

pull/23/head
kay.one 12 years ago
parent ada326af59
commit d41f26a4e7

@ -1,64 +0,0 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.HelperTests.XElementHelperTests
{
[TestFixture]
public class ParseDayOfWeekFixture : CoreTest
{
[Test]
public void should_return_null_if_xelement_is_null()
{
XElement test = null;
test.ConvertToDayOfWeek().Should().Be(null);
}
[Test]
public void should_return_null_if_value_is_null()
{
new XElement("airday", null).ConvertToDayOfWeek().Should().Be(null);
}
[Test]
public void should_return_null_if_value_is_empty()
{
new XElement("airday", "").ConvertToDayOfWeek().Should().Be(null);
}
[Test]
public void should_return_null_if_value_is_daily()
{
new XElement("airday", "Daily").ConvertToDayOfWeek().Should().Be(null);
}
[Test]
public void should_return_null_if_value_is_weekdays()
{
new XElement("airday", "Weekdays").ConvertToDayOfWeek().Should().Be(null);
}
[TestCase("Sunday", DayOfWeek.Sunday)]
[TestCase("Monday", DayOfWeek.Monday)]
[TestCase("Tuesday", DayOfWeek.Tuesday)]
[TestCase("Wednesday", DayOfWeek.Wednesday)]
[TestCase("Thursday", DayOfWeek.Thursday)]
[TestCase("Friday", DayOfWeek.Friday)]
[TestCase("Saturday", DayOfWeek.Saturday)]
public void should_return_dayOfWeek_when_it_is_valid(string value, DayOfWeek expected)
{
new XElement("airday", value).ConvertToDayOfWeek().Should().Be(expected);
}
}
}

@ -1,70 +0,0 @@

using System;
using System.Collections.Generic;
using System.Xml.Linq;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.HelperTests.XElementHelperTests
{
[TestFixture]
public class XElementHelperTest : CoreTest
{
[Test]
public void Int32_should_return_zero_when_xelement_is_null()
{
XElement test = null;
test.ConvertTo<Int32>().Should().Be(0);
}
[Test]
public void Int32_should_return_zero_when_value_is_null()
{
new XElement("test", null).ConvertTo<Int32>().Should().Be(0);
}
[Test]
public void Int32_should_return_value_when_value_is_an_int()
{
new XElement("test", 10).ConvertTo<Int32>().Should().Be(10);
}
[Test]
public void Nullable_Int32_should_return_null_when_xelement_is_null()
{
XElement test = null;
test.ConvertTo<Nullable<Int32>>().Should().Be(null);
}
[Test]
public void DateTime_should_return_zero_when_xelement_is_null()
{
XElement test = null;
test.ConvertTo<DateTime>().Should().Be(DateTime.MinValue);
}
[Test]
public void DateTime_should_return_zero_when_value_is_null()
{
new XElement("test", null).ConvertTo<DateTime>().Should().Be(DateTime.MinValue);
}
[Test]
public void DateTime_should_return_value_when_value_is_a_date()
{
var date = DateTime.Today;
new XElement("test", date.ToString()).ConvertTo<DateTime>().Should().Be(date);
}
}
}

@ -133,7 +133,6 @@
<Compile Include="Framework\CoreTest.cs" />
<Compile Include="Framework\DbTest.cs" />
<Compile Include="Framework\NBuilderExtensions.cs" />
<Compile Include="HelperTests\XElementHelperTests\ConvertToTFixture.cs" />
<Compile Include="IndexerSearchTests\SearchDefinitionFixture.cs" />
<Compile Include="JobTests\JobRepositoryFixture.cs" />
<Compile Include="JobTests\RenameSeasonJobFixture.cs" />
@ -144,7 +143,6 @@
<Compile Include="MediaFileTests\EpisodeFileMoverFixture.cs" />
<Compile Include="MetadataSourceTests\TracktProxyFixture.cs" />
<Compile Include="RootFolderTests\FreeSpaceOnDrivesFixture.cs" />
<Compile Include="HelperTests\XElementHelperTests\ConvertToDayOfWeekFixture.cs" />
<Compile Include="Qualities\QualityFixture.cs" />
<Compile Include="EpisodeParseResultTest.cs" />
<Compile Include="JobTests\PostDownloadScanJobFixture.cs" />

@ -1,9 +1,7 @@
using System;
using System.Linq;
using System;
using Newtonsoft.Json;
using NzbDrone.Core.Download.Clients.Sabnzbd;
namespace NzbDrone.Core.Helpers
namespace NzbDrone.Core.Download.Clients.Sabnzbd.JsonConverters
{
public class SabnzbdPriorityTypeConverter : JsonConverter
{

@ -1,8 +1,8 @@
using System;
using System;
using System.Linq;
using Newtonsoft.Json;
namespace NzbDrone.Core.Helpers
namespace NzbDrone.Core.Download.Clients.Sabnzbd.JsonConverters
{
public class SabnzbdQueueTimeConverter : JsonConverter
{

@ -1,6 +1,7 @@
using System;
using System.Linq;
using Newtonsoft.Json;
using NzbDrone.Core.Download.Clients.Sabnzbd.JsonConverters;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model;

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace NzbDrone.Core.Helpers
{

@ -1,49 +0,0 @@
using System;
using System.ComponentModel;
using System.Linq;
using System.Xml.Linq;
namespace NzbDrone.Core.Helpers
{
public static class XElementHelper
{
public static T ConvertTo<T>(this XElement element)
{
if (element == null)
return default(T);
if (String.IsNullOrEmpty(element.Value))
return default(T);
var converter = TypeDescriptor.GetConverter(typeof(T));
try
{
return (T)converter.ConvertFromString(element.Value);
}
catch
{
return default(T);
}
}
public static DayOfWeek? ConvertToDayOfWeek(this XElement element)
{
if (element == null)
return null;
if (String.IsNullOrWhiteSpace(element.Value))
return null;
try
{
return (DayOfWeek)Enum.Parse(typeof(DayOfWeek), element.Value);
}
catch (Exception)
{
}
return null;
}
}
}

@ -1,11 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace NzbDrone.Core.Helpers.Converters
namespace NzbDrone.Core.Model.Nzbx.JsonConverter
{
public class EpochDateTimeConverter : DateTimeConverterBase
{

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using NzbDrone.Core.Helpers.Converters;
using NzbDrone.Core.Model.Nzbx.JsonConverter;
namespace NzbDrone.Core.Model.Nzbx
{

@ -230,6 +230,8 @@
<Compile Include="DecisionEngine\Specifications\Search\SingleEpisodeMatchSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\UpgradeDiskSpecification.cs" />
<Compile Include="DecisionEngine\Specifications\UpgradeHistorySpecification.cs" />
<Compile Include="Download\Clients\Sabnzbd\JsonConverters\SabnzbdPriorityTypeConverter.cs" />
<Compile Include="Download\Clients\Sabnzbd\JsonConverters\SabnzbdQueueTimeConverter.cs" />
<Compile Include="Download\Clients\Sabnzbd\SabAutoConfigureService.cs" />
<Compile Include="Download\DownloadClientProvider.cs" />
<Compile Include="Download\EpisodeDownloadedEvent.cs" />
@ -237,11 +239,8 @@
<Compile Include="Download\SeriesRenamedEvent.cs" />
<Compile Include="ExternalNotification\ExternalNotificationRepository.cs" />
<Compile Include="Fluent.cs" />
<Compile Include="Helpers\Converters\EpochDateTimeConverter.cs" />
<Compile Include="Helpers\SabnzbdQueueTimeConverter.cs" />
<Compile Include="Model\Nzbx\JsonConverter\EpochDateTimeConverter.cs" />
<Compile Include="Helpers\SortHelper.cs" />
<Compile Include="Helpers\SabnzbdPriorityTypeConverter.cs" />
<Compile Include="Helpers\XElementHelper.cs" />
<Compile Include="History\HistoryRepository.cs" />
<Compile Include="IndexerSearch\Definitions\DailyEpisodeSearchDefinition.cs" />
<Compile Include="IndexerSearch\Definitions\PartialSeasonSearchDefinition.cs" />

Loading…
Cancel
Save