2011-07-09 18:19:33 +00:00
|
|
|
|
// ReSharper disable RedundantUsingDirective
|
|
|
|
|
|
|
|
|
|
using System;
|
2011-11-14 00:22:18 +00:00
|
|
|
|
|
2011-07-09 18:19:33 +00:00
|
|
|
|
using Moq;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using NzbDrone.Core.Model.Xbmc;
|
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
|
|
|
|
using NzbDrone.Core.Providers.Xbmc;
|
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
2011-11-14 00:22:18 +00:00
|
|
|
|
using NzbDrone.Test.Common.AutoMoq;
|
2011-07-09 18:19:33 +00:00
|
|
|
|
|
2011-10-20 23:42:17 +00:00
|
|
|
|
namespace NzbDrone.Core.Test.ProviderTests
|
2011-07-09 18:19:33 +00:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
// ReSharper disable InconsistentNaming
|
2011-11-13 07:27:16 +00:00
|
|
|
|
public class EventClientProviderTest : CoreTest
|
2011-07-09 18:19:33 +00:00
|
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
public void SendNotification_true()
|
|
|
|
|
{
|
|
|
|
|
//Setup
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
|
|
|
|
var header = "NzbDrone Test";
|
|
|
|
|
var message = "Test Message!";
|
|
|
|
|
var address = "localhost";
|
|
|
|
|
|
|
|
|
|
var fakeUdp = mocker.GetMock<UdpProvider>();
|
|
|
|
|
fakeUdp.Setup(s => s.Send(address, UdpProvider.PacketType.Notification, It.IsAny<byte[]>())).Returns(true);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<EventClientProvider>().SendNotification(header, message, IconType.Jpeg, "NzbDrone.jpg", address);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
Assert.AreEqual(true, result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void SendNotification_false()
|
|
|
|
|
{
|
|
|
|
|
//Setup
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
|
|
|
|
var header = "NzbDrone Test";
|
|
|
|
|
var message = "Test Message!";
|
|
|
|
|
var address = "localhost";
|
|
|
|
|
|
|
|
|
|
var fakeUdp = mocker.GetMock<UdpProvider>();
|
|
|
|
|
fakeUdp.Setup(s => s.Send(address, UdpProvider.PacketType.Notification, It.IsAny<byte[]>())).Returns(false);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<EventClientProvider>().SendNotification(header, message, IconType.Jpeg, "NzbDrone.jpg", address);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
Assert.AreEqual(false, result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void SendAction_Update_true()
|
|
|
|
|
{
|
|
|
|
|
//Setup
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
|
|
|
|
var path = @"C:\Test\TV\30 Rock";
|
|
|
|
|
var command = String.Format("ExecBuiltIn(UpdateLibrary(video,{0}))", path);
|
|
|
|
|
var address = "localhost";
|
|
|
|
|
|
|
|
|
|
var fakeUdp = mocker.GetMock<UdpProvider>();
|
|
|
|
|
fakeUdp.Setup(s => s.Send(address, UdpProvider.PacketType.Action, It.IsAny<byte[]>())).Returns(true);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<EventClientProvider>().SendAction(address, ActionType.ExecBuiltin, command);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
Assert.AreEqual(true, result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void SendAction_Update_false()
|
|
|
|
|
{
|
|
|
|
|
//Setup
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
|
|
|
|
var path = @"C:\Test\TV\30 Rock";
|
|
|
|
|
var command = String.Format("ExecBuiltIn(UpdateLibrary(video,{0}))", path);
|
|
|
|
|
var address = "localhost";
|
|
|
|
|
|
|
|
|
|
var fakeUdp = mocker.GetMock<UdpProvider>();
|
|
|
|
|
fakeUdp.Setup(s => s.Send(address, UdpProvider.PacketType.Action, It.IsAny<byte[]>())).Returns(false);
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<EventClientProvider>().SendAction(address, ActionType.ExecBuiltin, command);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
Assert.AreEqual(false, result);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|