From 0894fc0e777b1f49481a39d7e19f614599605199 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 30 Aug 2013 23:19:19 -0700 Subject: [PATCH] Fixing CommandIntegrationTest - for now --- .../Messaging/Tracking/TrackedCommand.cs | 6 +++- .../CommandIntegerationTests.cs | 29 +++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/NzbDrone.Common/Messaging/Tracking/TrackedCommand.cs b/NzbDrone.Common/Messaging/Tracking/TrackedCommand.cs index cb00dd8c7..37f69de88 100644 --- a/NzbDrone.Common/Messaging/Tracking/TrackedCommand.cs +++ b/NzbDrone.Common/Messaging/Tracking/TrackedCommand.cs @@ -12,7 +12,11 @@ namespace NzbDrone.Common.Messaging.Tracking public DateTime StateChangeTime { get; set; } public TimeSpan Runtime { get; set; } public Exception Exception { get; set; } - + + public TrackedCommand() + { + } + public TrackedCommand(ICommand command, CommandState state) { Id = command.CommandId; diff --git a/NzbDrone.Integration.Test/CommandIntegerationTests.cs b/NzbDrone.Integration.Test/CommandIntegerationTests.cs index c1e06bac1..af3342c2b 100644 --- a/NzbDrone.Integration.Test/CommandIntegerationTests.cs +++ b/NzbDrone.Integration.Test/CommandIntegerationTests.cs @@ -1,5 +1,10 @@ -using NUnit.Framework; +using System.Net; +using FluentAssertions; +using NUnit.Framework; using NzbDrone.Api.Commands; +using NzbDrone.Common.Messaging.Tracking; +using NzbDrone.Common.Serializer; +using RestSharp; namespace NzbDrone.Integration.Test { @@ -9,7 +14,27 @@ namespace NzbDrone.Integration.Test [Test] public void should_be_able_to_run_rss_sync() { - Commands.Post(new CommandResource {Command = "rsssync"}); + var request = new RestRequest("command") + { + RequestFormat = DataFormat.Json, + Method = Method.POST + }; + + request.AddBody(new CommandResource {Command = "rsssync"}); + + var restClient = new RestClient("http://localhost:8989/api"); + var response = restClient.Execute(request); + + if (response.ErrorException != null) + { + throw response.ErrorException; + } + + response.ErrorMessage.Should().BeBlank(); + response.StatusCode.Should().Be(HttpStatusCode.Created); + + var trackedCommand = Json.Deserialize(response.Content); + trackedCommand.Id.Should().NotBeNullOrEmpty(); } } } \ No newline at end of file