test clean up.

This commit is contained in:
Keivan Beigi 2013-03-28 15:07:09 -07:00
commit a221994cd7
90 changed files with 779 additions and 804 deletions

View file

@ -1,4 +1,4 @@
// ReSharper disable RedundantUsingDirective

using System;
using System.IO;
@ -22,7 +22,7 @@ using NzbDrone.Test.Common.AutoMoq;
namespace NzbDrone.Core.Test.ProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
public class PlexProviderTest : CoreTest
{
private void WithSingleClient()
@ -49,7 +49,7 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void GetSectionKeys_should_return_single_section_key_when_only_one_show_section()
{
//Setup
var response = "<MediaContainer size=\"1\" mediaTagPrefix=\"/system/bundle/media/flags/\" mediaTagVersion=\"1329809559\" title1=\"Plex Library\" identifier=\"com.plexapp.plugins.library\"><Directory refreshing=\"0\" key=\"5\" type=\"show\" title=\"TV Shows\" art=\"/:/resources/show-fanart.jpg\" agent=\"com.plexapp.agents.thetvdb\" scanner=\"Plex Series Scanner\" language=\"en\" updatedAt=\"1329810350\"><Location path=\"C:/Test/TV\"/></Directory></MediaContainer>";
Stream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(response));
@ -57,10 +57,10 @@ namespace NzbDrone.Core.Test.ProviderTests
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadStream("http://localhost:32400/library/sections", null))
.Returns(stream);
//Act
var result = Mocker.Resolve<PlexProvider>().GetSectionKeys("localhost:32400");
//Assert
result.Should().HaveCount(1);
result.First().Should().Be(5);
}
@ -68,7 +68,7 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void GetSectionKeys_should_return_single_section_key_when_only_one_show_section_with_other_sections()
{
//Setup
var response = "<MediaContainer size=\"1\" mediaTagPrefix=\"/system/bundle/media/flags/\" mediaTagVersion=\"1329809559\" title1=\"Plex Library\" identifier=\"com.plexapp.plugins.library\"><Directory refreshing=\"0\" key=\"5\" type=\"show\" title=\"TV Shows\" art=\"/:/resources/show-fanart.jpg\" agent=\"com.plexapp.agents.thetvdb\" scanner=\"Plex Series Scanner\" language=\"en\" updatedAt=\"1329810350\"><Location path=\"C:/Test/TV\"/></Directory><Directory refreshing=\"0\" key=\"7\" type=\"movie\" title=\"TV Shows\" art=\"/:/resources/show-fanart.jpg\" agent=\"com.plexapp.agents.thetvdb\" scanner=\"Plex Series Scanner\" language=\"en\" updatedAt=\"1329810350\"><Location path=\"C:/Test/TV\"/></Directory></MediaContainer>";
Stream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(response));
@ -76,10 +76,10 @@ namespace NzbDrone.Core.Test.ProviderTests
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadStream("http://localhost:32400/library/sections", null))
.Returns(stream);
//Act
var result = Mocker.Resolve<PlexProvider>().GetSectionKeys("localhost:32400");
//Assert
result.Should().HaveCount(1);
result.First().Should().Be(5);
}
@ -87,7 +87,7 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void GetSectionKeys_should_return_multiple_section_keys_when_there_are_multiple_show_sections()
{
//Setup
var response = "<MediaContainer size=\"1\" mediaTagPrefix=\"/system/bundle/media/flags/\" mediaTagVersion=\"1329809559\" title1=\"Plex Library\" identifier=\"com.plexapp.plugins.library\"><Directory refreshing=\"0\" key=\"5\" type=\"show\" title=\"TV Shows\" art=\"/:/resources/show-fanart.jpg\" agent=\"com.plexapp.agents.thetvdb\" scanner=\"Plex Series Scanner\" language=\"en\" updatedAt=\"1329810350\"><Location path=\"C:/Test/TV\"/></Directory><Directory refreshing=\"0\" key=\"6\" type=\"show\" title=\"TV Shows\" art=\"/:/resources/show-fanart.jpg\" agent=\"com.plexapp.agents.thetvdb\" scanner=\"Plex Series Scanner\" language=\"en\" updatedAt=\"1329810350\"><Location path=\"C:/Test/TV\"/></Directory></MediaContainer>";
Stream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(response));
@ -95,10 +95,10 @@ namespace NzbDrone.Core.Test.ProviderTests
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadStream("http://localhost:32400/library/sections", null))
.Returns(stream);
//Act
var result = Mocker.Resolve<PlexProvider>().GetSectionKeys("localhost:32400");
//Assert
result.Should().HaveCount(2);
result.First().Should().Be(5);
result.Last().Should().Be(6);
@ -107,7 +107,7 @@ namespace NzbDrone.Core.Test.ProviderTests
[Test]
public void UpdateSection_should_update_section()
{
//Setup
var response = "";
Stream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(response));
@ -115,17 +115,17 @@ namespace NzbDrone.Core.Test.ProviderTests
Mocker.GetMock<HttpProvider>().Setup(s => s.DownloadString("http://localhost:32400/library/sections/5/refresh"))
.Returns(response);
//Act
Mocker.Resolve<PlexProvider>().UpdateSection("localhost:32400", 5);
//Assert
}
[Test]
public void Notify_should_send_notification_for_single_client_when_only_one_is_configured()
{
//Setup
WithSingleClient();
const string header = "Test Header";
@ -137,17 +137,17 @@ namespace NzbDrone.Core.Test.ProviderTests
fakeHttp.Setup(s => s.DownloadString(expectedUrl))
.Returns("ok");
//Act
Mocker.Resolve<PlexProvider>().Notify(header, message);
//Assert
fakeHttp.Verify(v => v.DownloadString(expectedUrl), Times.Once());
}
[Test]
public void Notify_should_send_notifcation_to_all_configured_clients()
{
//Setup
WithMultipleClients();
const string header = "Test Header";
@ -157,17 +157,17 @@ namespace NzbDrone.Core.Test.ProviderTests
fakeHttp.Setup(s => s.DownloadString(It.IsAny<string>()))
.Returns("ok");
//Act
Mocker.Resolve<PlexProvider>().Notify(header, message);
//Assert
fakeHttp.Verify(v => v.DownloadString(It.IsAny<string>()), Times.Exactly(2));
}
[Test]
public void Notify_should_send_notification_with_credentials_when_configured()
{
//Setup
WithSingleClient();
WithClientCredentials();
@ -180,17 +180,17 @@ namespace NzbDrone.Core.Test.ProviderTests
fakeHttp.Setup(s => s.DownloadString(expectedUrl, "plex", "plex"))
.Returns("ok");
//Act
Mocker.Resolve<PlexProvider>().Notify(header, message);
//Assert
fakeHttp.Verify(v => v.DownloadString(expectedUrl, "plex", "plex"), Times.Once());
}
[Test]
public void Notify_should_send_notification_with_credentials_when_configured_for_all_clients()
{
//Setup
WithMultipleClients();
WithClientCredentials();
@ -201,10 +201,10 @@ namespace NzbDrone.Core.Test.ProviderTests
fakeHttp.Setup(s => s.DownloadString(It.IsAny<string>(), "plex", "plex"))
.Returns("ok");
//Act
Mocker.Resolve<PlexProvider>().Notify(header, message);
//Assert
fakeHttp.Verify(v => v.DownloadString(It.IsAny<string>(), "plex", "plex"), Times.Exactly(2));
}
}