mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 13:33:34 -07:00
Notifications can be tested
Notification ImplementationType was added for showing in UI (Humanized/Title cased of Implementation)
This commit is contained in:
parent
1f4cf0034e
commit
8cac7ed1cd
34 changed files with 418 additions and 328 deletions
|
@ -9,130 +9,40 @@ namespace NzbDrone.Core.Test.NotificationTests
|
|||
{
|
||||
[Explicit]
|
||||
[TestFixture]
|
||||
public class ProwlProviderTest : CoreTest
|
||||
public class ProwlProviderTest : CoreTest<ProwlService>
|
||||
{
|
||||
private const string _apiKey = "c3bdc0f48168f72d546cc6872925b160f5cbffc1";
|
||||
private const string _apiKey2 = "46a710a46b111b0b8633819b0d8a1e0272a3affa";
|
||||
private const string _apiKey = "66e9f688b512152eb2688f0486ae542c76e564a2";
|
||||
|
||||
private const string _badApiKey = "1234567890abcdefghijklmnopqrstuvwxyz1234";
|
||||
|
||||
[Test]
|
||||
public void Verify_should_return_true_for_a_valid_apiKey()
|
||||
public void Verify_should_not_throw_for_a_valid_apiKey()
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
var result = Mocker.Resolve<ProwlProvider>().Verify(_apiKey);
|
||||
|
||||
|
||||
result.Should().BeTrue();
|
||||
Subject.Verify(_apiKey);
|
||||
ExceptionVerification.ExpectedWarns(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Verify_should_return_false_for_an_invalid_apiKey()
|
||||
public void Verify_should_throw_for_an_invalid_apiKey()
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
var result = Mocker.Resolve<ProwlProvider>().Verify(_badApiKey);
|
||||
|
||||
Assert.Throws<InvalidApiKeyException>(() => Subject.Verify(_badApiKey));
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
result.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SendNotification_should_return_true_for_a_valid_apiKey()
|
||||
public void SendNotification_should_not_throw_for_a_valid_apiKey()
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
var result = Mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _apiKey);
|
||||
|
||||
|
||||
result.Should().BeTrue();
|
||||
Subject.SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _apiKey);
|
||||
ExceptionVerification.ExpectedWarns(0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SendNotification_should_return_false_for_an_invalid_apiKey()
|
||||
public void SendNotification_should_log_a_warning_for_an_invalid_apiKey()
|
||||
{
|
||||
|
||||
|
||||
Subject.SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _badApiKey);
|
||||
|
||||
|
||||
var result = Mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _badApiKey);
|
||||
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
result.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SendNotification_should_alert_with_high_priority()
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
var result = Mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone (High)", _apiKey, NotificationPriority.High);
|
||||
|
||||
|
||||
result.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SendNotification_should_alert_with_VeryLow_priority()
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
var result = Mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone (VeryLow)", _apiKey, NotificationPriority.VeryLow);
|
||||
|
||||
|
||||
result.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SendNotification_should_have_a_call_back_url()
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
var result = Mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _apiKey, NotificationPriority.Normal, "http://www.nzbdrone.com");
|
||||
|
||||
|
||||
result.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SendNotification_should_return_true_for_two_valid_apiKey()
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
var result = Mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _apiKey + ", " + _apiKey2);
|
||||
|
||||
|
||||
result.Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SendNotification_should_return_true_for_valid_apiKey_with_bad_apiKey()
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
var result = Mocker.Resolve<ProwlProvider>().SendNotification("NzbDrone Test", "This is a test message from NzbDrone", _apiKey + ", " + _badApiKey);
|
||||
|
||||
|
||||
result.Should().BeTrue();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue