mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 10:47:08 -07:00
Cleaned up progress notification.
This commit is contained in:
parent
6e9a6313ff
commit
0a70c836df
5 changed files with 86 additions and 35 deletions
|
@ -0,0 +1,71 @@
|
|||
using System.Linq;
|
||||
using System.Threading;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Providers;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.NotificationProviderTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class NotificationProviderFixture
|
||||
{
|
||||
NotificationProvider _notificationProvider;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_notificationProvider = new NotificationProvider();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void current_notification_should_return_null_at_start()
|
||||
{
|
||||
_notificationProvider.GetCurrent().Should().BeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_current_on_active_notifications()
|
||||
{
|
||||
var fakeNotification = new ProgressNotification("Title");
|
||||
_notificationProvider.Register(fakeNotification);
|
||||
|
||||
_notificationProvider.GetCurrent().Should().Be(fakeNotification);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_last_if_recently_completed()
|
||||
{
|
||||
var fakeNotification = new ProgressNotification("Title");
|
||||
_notificationProvider.Register(fakeNotification);
|
||||
fakeNotification.Dispose();
|
||||
|
||||
_notificationProvider.GetCurrent().Should().Be(fakeNotification);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_null_if_completed_long_time_ago()
|
||||
{
|
||||
var fakeNotification = new ProgressNotification("Title");
|
||||
_notificationProvider.Register(fakeNotification);
|
||||
fakeNotification.Dispose();
|
||||
|
||||
Thread.Sleep(4000);
|
||||
|
||||
_notificationProvider.GetCurrent().Should().BeNull();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void new_notification_should_replace_old_one()
|
||||
{
|
||||
var oldNotification = new ProgressNotification("Title");
|
||||
_notificationProvider.Register(oldNotification);
|
||||
|
||||
var newNotification = new ProgressNotification("Title");
|
||||
_notificationProvider.Register(newNotification);
|
||||
|
||||
_notificationProvider.GetCurrent().Should().Be(newNotification);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue