diff --git a/src/NzbDrone.Api/ClientSchema/SchemaBuilder.cs b/src/NzbDrone.Api/ClientSchema/SchemaBuilder.cs index 095ed6b41..8a8a20cef 100644 --- a/src/NzbDrone.Api/ClientSchema/SchemaBuilder.cs +++ b/src/NzbDrone.Api/ClientSchema/SchemaBuilder.cs @@ -77,7 +77,7 @@ namespace NzbDrone.Api.ClientSchema propertyInfo.SetValue(target, value, null); } - if (propertyInfo.PropertyType == typeof(Int64)) + else if (propertyInfo.PropertyType == typeof(Int64)) { var value = Convert.ToInt64(field.Value); propertyInfo.SetValue(target, value, null); diff --git a/src/NzbDrone.Integration.Test/Client/NotificationClient.cs b/src/NzbDrone.Integration.Test/Client/NotificationClient.cs new file mode 100644 index 000000000..f93fa393a --- /dev/null +++ b/src/NzbDrone.Integration.Test/Client/NotificationClient.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; +using NzbDrone.Api.Indexers; +using NzbDrone.Api.Notifications; +using RestSharp; + +namespace NzbDrone.Integration.Test.Client +{ + public class NotificationClient : ClientBase + { + public NotificationClient(IRestClient restClient, string apiKey) + : base(restClient, apiKey) + { + } + + public List Schema() + { + var request = BuildRequest("/schema"); + return Get>(request); + } + } +} \ No newline at end of file diff --git a/src/NzbDrone.Integration.Test/IntegrationTest.cs b/src/NzbDrone.Integration.Test/IntegrationTest.cs index aac665ea1..fffac3b0a 100644 --- a/src/NzbDrone.Integration.Test/IntegrationTest.cs +++ b/src/NzbDrone.Integration.Test/IntegrationTest.cs @@ -35,6 +35,7 @@ namespace NzbDrone.Integration.Test protected IndexerClient Indexers; protected EpisodeClient Episodes; protected ClientBase NamingConfig; + protected NotificationClient Notifications; private NzbDroneRunner _runner; private List _signalRReceived; @@ -80,6 +81,7 @@ namespace NzbDrone.Integration.Test Indexers = new IndexerClient(RestClient, _runner.ApiKey); Episodes = new EpisodeClient(RestClient, _runner.ApiKey); NamingConfig = new ClientBase(RestClient, _runner.ApiKey, "config/naming"); + Notifications = new NotificationClient(RestClient, _runner.ApiKey); } [TestFixtureTearDown] diff --git a/src/NzbDrone.Integration.Test/NotificationIntegrationFixture.cs b/src/NzbDrone.Integration.Test/NotificationIntegrationFixture.cs new file mode 100644 index 000000000..fcc85cd35 --- /dev/null +++ b/src/NzbDrone.Integration.Test/NotificationIntegrationFixture.cs @@ -0,0 +1,43 @@ +using System; +using System.Linq; +using FluentAssertions; +using NUnit.Framework; + + +namespace NzbDrone.Integration.Test +{ + [TestFixture] + public class NotificationIntegrationFixture : IntegrationTest + { + [Test] + public void should_not_have_any_default_notifications() + { + var notifications = Notifications.All(); + + notifications.Should().BeEmpty(); + } + + [Test] + public void should_be_able_to_get_schema() + { + var schema = Notifications.Schema(); + + schema.Should().NotBeEmpty(); + schema.Should().Contain(c => string.IsNullOrWhiteSpace(c.Name)); + } + + [Test] + public void should_be_able_to_add_a_new_notification() + { + var schema = Notifications.Schema(); + + var xbmc = schema.Single(s => s.Implementation.Equals("Xbmc", StringComparison.InvariantCultureIgnoreCase)); + + xbmc.Name = "Test XBMC"; + xbmc.Fields.Single(f => f.Name.Equals("Host")).Value = "localhost"; + + var result = Notifications.Post(xbmc); + Notifications.Delete(result.Id); + } + } +} \ No newline at end of file diff --git a/src/NzbDrone.Integration.Test/NzbDrone.Integration.Test.csproj b/src/NzbDrone.Integration.Test/NzbDrone.Integration.Test.csproj index c984ef79c..13f3b7d4e 100644 --- a/src/NzbDrone.Integration.Test/NzbDrone.Integration.Test.csproj +++ b/src/NzbDrone.Integration.Test/NzbDrone.Integration.Test.csproj @@ -97,11 +97,13 @@ + +