2013-08-26 19:35:53 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2013-08-18 22:19:55 +00:00
|
|
|
|
using System.IO;
|
2013-04-22 03:18:08 +00:00
|
|
|
|
using FluentAssertions;
|
2013-08-18 22:19:55 +00:00
|
|
|
|
using Microsoft.AspNet.SignalR.Client;
|
|
|
|
|
using Microsoft.AspNet.SignalR.Client.Transports;
|
2013-04-22 03:18:08 +00:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using NzbDrone.Api.RootFolders;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Integration.Test
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class RootFolderIntegrationTest : IntegrationTest
|
|
|
|
|
{
|
2013-08-18 22:19:55 +00:00
|
|
|
|
private Connection _connection;
|
|
|
|
|
private List<object> _signalRReceived;
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
|
|
|
|
_signalRReceived = new List<object>();
|
|
|
|
|
_connection = new Connection("http://localhost:8989/signalr/rootfolder");
|
|
|
|
|
_connection.Start(new LongPollingTransport()).ContinueWith(task =>
|
|
|
|
|
{
|
|
|
|
|
if (task.IsFaulted)
|
|
|
|
|
{
|
|
|
|
|
Assert.Fail("SignalrConnection failed. {0}", task.Exception.GetBaseException());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
_connection.Received += _connection_Received;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void _connection_Received(string obj)
|
|
|
|
|
{
|
|
|
|
|
_signalRReceived.Add(obj);
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-22 03:18:08 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void should_have_no_root_folder_initially()
|
|
|
|
|
{
|
|
|
|
|
RootFolders.All().Should().BeEmpty();
|
|
|
|
|
|
|
|
|
|
var rootFolder = new RootFolderResource
|
|
|
|
|
{
|
2013-08-26 19:35:53 +00:00
|
|
|
|
Path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
|
2013-04-22 03:18:08 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var postResponse = RootFolders.Post(rootFolder);
|
|
|
|
|
|
|
|
|
|
postResponse.Id.Should().NotBe(0);
|
|
|
|
|
postResponse.FreeSpace.Should().NotBe(0);
|
|
|
|
|
|
|
|
|
|
RootFolders.All().Should().OnlyContain(c => c.Id == postResponse.Id);
|
|
|
|
|
|
|
|
|
|
|
2013-04-24 01:56:00 +00:00
|
|
|
|
RootFolders.Delete(postResponse.Id);
|
|
|
|
|
|
|
|
|
|
RootFolders.All().Should().BeEmpty();
|
|
|
|
|
}
|
2013-08-31 20:31:58 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void invalid_path_should_return_bad_request()
|
|
|
|
|
{
|
|
|
|
|
var rootFolder = new RootFolderResource
|
|
|
|
|
{
|
|
|
|
|
Path = "invalid_path"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var postResponse = RootFolders.InvalidPost(rootFolder);
|
|
|
|
|
postResponse.Should().NotBeEmpty();
|
|
|
|
|
}
|
2013-04-22 03:18:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|