1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-21 22:05:38 -04:00

New: Rebuilt Completed/Failed download handling from scratch

This commit is contained in:
Keivan Beigi
2014-12-18 16:26:42 -08:00
parent 264bb66c16
commit a6d34caf2c
79 changed files with 1221 additions and 2389 deletions
@@ -0,0 +1,69 @@
using System;
using System.Threading;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common.TPL;
namespace NzbDrone.Common.Test.TPLTests
{
[TestFixture]
public class DebouncerFixture
{
public class Counter
{
public int Count { get; private set; }
public void Hit()
{
Count++;
}
}
[Test]
public void should_hold_the_call_for_debounce_duration()
{
var counter = new Counter();
var debounceFunction = new Debouncer(counter.Hit, TimeSpan.FromMilliseconds(50));
debounceFunction.Execute();
debounceFunction.Execute();
debounceFunction.Execute();
counter.Count.Should().Be(0);
Thread.Sleep(100);
counter.Count.Should().Be(1);
}
[Test]
public void should_throttle_cals()
{
var counter = new Counter();
var debounceFunction = new Debouncer(counter.Hit, TimeSpan.FromMilliseconds(50));
debounceFunction.Execute();
debounceFunction.Execute();
debounceFunction.Execute();
counter.Count.Should().Be(0);
Thread.Sleep(200);
debounceFunction.Execute();
debounceFunction.Execute();
debounceFunction.Execute();
Thread.Sleep(200);
counter.Count.Should().Be(2);
}
}
}