Radarr/NzbDrone.Core.Test/ProviderTests/EventClientProviderTest.cs

98 lines
3.0 KiB
C#
Raw Normal View History

// ReSharper disable RedundantUsingDirective
using System;
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;
using NzbDrone.Test.Common.AutoMoq;
namespace NzbDrone.Core.Test.ProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
2011-11-13 07:27:16 +00:00
public class EventClientProviderTest : CoreTest
{
[Test]
public void SendNotification_true()
{
//Setup
2011-12-15 04:15:53 +00:00
var header = "NzbDrone Test";
var message = "Test Message!";
var address = "localhost";
2011-12-15 04:15:53 +00:00
var fakeUdp = Mocker.GetMock<UdpProvider>();
fakeUdp.Setup(s => s.Send(address, UdpProvider.PacketType.Notification, It.IsAny<byte[]>())).Returns(true);
//Act
2011-12-15 04:15:53 +00:00
var result = Mocker.Resolve<EventClientProvider>().SendNotification(header, message, IconType.Jpeg, "NzbDrone.jpg", address);
//Assert
Assert.AreEqual(true, result);
}
[Test]
public void SendNotification_false()
{
//Setup
2011-12-15 04:15:53 +00:00
var header = "NzbDrone Test";
var message = "Test Message!";
var address = "localhost";
2011-12-15 04:15:53 +00:00
var fakeUdp = Mocker.GetMock<UdpProvider>();
fakeUdp.Setup(s => s.Send(address, UdpProvider.PacketType.Notification, It.IsAny<byte[]>())).Returns(false);
//Act
2011-12-15 04:15:53 +00:00
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
2011-12-15 04:15:53 +00:00
var path = @"C:\Test\TV\30 Rock";
var command = String.Format("ExecBuiltIn(UpdateLibrary(video,{0}))", path);
var address = "localhost";
2011-12-15 04:15:53 +00:00
var fakeUdp = Mocker.GetMock<UdpProvider>();
fakeUdp.Setup(s => s.Send(address, UdpProvider.PacketType.Action, It.IsAny<byte[]>())).Returns(true);
//Act
2011-12-15 04:15:53 +00:00
var result = Mocker.Resolve<EventClientProvider>().SendAction(address, ActionType.ExecBuiltin, command);
//Assert
Assert.AreEqual(true, result);
}
[Test]
public void SendAction_Update_false()
{
//Setup
2011-12-15 04:15:53 +00:00
var path = @"C:\Test\TV\30 Rock";
var command = String.Format("ExecBuiltIn(UpdateLibrary(video,{0}))", path);
var address = "localhost";
2011-12-15 04:15:53 +00:00
var fakeUdp = Mocker.GetMock<UdpProvider>();
fakeUdp.Setup(s => s.Send(address, UdpProvider.PacketType.Action, It.IsAny<byte[]>())).Returns(false);
//Act
2011-12-15 04:15:53 +00:00
var result = Mocker.Resolve<EventClientProvider>().SendAction(address, ActionType.ExecBuiltin, command);
//Assert
Assert.AreEqual(false, result);
}
}
}