Fixed: Issue saving notifications

pull/46/merge
Mark McDowall 11 years ago
parent fb6e365c1a
commit 36a5eea951

@ -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);

@ -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<NotificationResource>
{
public NotificationClient(IRestClient restClient, string apiKey)
: base(restClient, apiKey)
{
}
public List<NotificationResource> Schema()
{
var request = BuildRequest("/schema");
return Get<List<NotificationResource>>(request);
}
}
}

@ -35,6 +35,7 @@ namespace NzbDrone.Integration.Test
protected IndexerClient Indexers;
protected EpisodeClient Episodes;
protected ClientBase<NamingConfigResource> NamingConfig;
protected NotificationClient Notifications;
private NzbDroneRunner _runner;
private List<SignalRMessage> _signalRReceived;
@ -80,6 +81,7 @@ namespace NzbDrone.Integration.Test
Indexers = new IndexerClient(RestClient, _runner.ApiKey);
Episodes = new EpisodeClient(RestClient, _runner.ApiKey);
NamingConfig = new ClientBase<NamingConfigResource>(RestClient, _runner.ApiKey, "config/naming");
Notifications = new NotificationClient(RestClient, _runner.ApiKey);
}
[TestFixtureTearDown]

@ -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);
}
}
}

@ -97,11 +97,13 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Client\ClientBase.cs" />
<Compile Include="Client\NotificationClient.cs" />
<Compile Include="Client\EpisodeClient.cs" />
<Compile Include="Client\IndexerClient.cs" />
<Compile Include="Client\ReleaseClient.cs" />
<Compile Include="Client\SeriesClient.cs" />
<Compile Include="CommandIntegerationTests.cs" />
<Compile Include="NotificationIntegrationFixture.cs" />
<Compile Include="SeriesEditorIntegrationTest.cs" />
<Compile Include="HistoryIntegrationTest.cs" />
<Compile Include="NamingConfigTests.cs" />

Loading…
Cancel
Save