Skip to content

Commit

Permalink
Merge pull request #35 from kougen/27-periodic-timer-should-have-a-me…
Browse files Browse the repository at this point in the history
…thod-overloading-without-a-cancellationtoken

minor changes
  • Loading branch information
joshika39 authored Apr 17, 2024
2 parents a116f7d + 26d717b commit e4e9b76
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using Infrastructure.Time;

namespace Implementation.Time.Factories;

public class ParentlessPeriodicStopwatchFactory
{
}
1 change: 0 additions & 1 deletion _src/Infrastructure/Time/IPeriodicStopwatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ public interface IPeriodicStopwatch : IAdjustableStopwatch, IDisposable
{
void ChangePeriod(int periodInMilliseconds);
void Resume();

}
}
6 changes: 4 additions & 2 deletions _src/_Tests/ImplementationTest/Time/StopwatchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Threading;
using System.Threading.Tasks;
using Implementation.Time;
using Implementation.Time.Factories;
using Infrastructure.Time;
using Infrastructure.Time.Listeners;
using Moq;
Expand All @@ -23,6 +24,7 @@ public async Task ST_0001_Given_Stopwatch_When_WaitAsyncIsCalled_Then_ListenerGe
{
await stopwatch.WaitAsync(250, listenerMock.Object);
}

stopwatch.Stop();
Assert.True(stopwatch.Elapsed.TotalMilliseconds > 2500);
listenerMock.Verify(l => l.RaiseTick(-1), Times.Exactly(10));
Expand All @@ -34,7 +36,7 @@ public void ST_0011_Given_Stopwatch_When_ManyListeners_Then_NotAffectsPerformanc
var cancellationTokenSource = new CancellationTokenSource();
using IStopwatch stopwatch = new DefaultStopwatch(cancellationTokenSource.Token);
Assert.NotNull(stopwatch);

var pWatchFactory = stopwatch.GetPeriodicStopwatchFactory();
using var pWatch1 = pWatchFactory.CreatePeriodicStopwatch(900);
var listenerMock1 = new Mock<ITickListener>();
Expand All @@ -47,4 +49,4 @@ public void ST_0011_Given_Stopwatch_When_ManyListeners_Then_NotAffectsPerformanc
Assert.False(pWatch1.IsRunning);
}
}
}
}

0 comments on commit e4e9b76

Please sign in to comment.