Fix service test

This commit is contained in:
Jordan Brown
2018-11-28 17:34:13 -05:00
parent c246ea9e62
commit 6ce1b5f026
2 changed files with 3 additions and 2 deletions
@@ -74,7 +74,7 @@ namespace Tgstation.Server.Host.Service
/// <returns>A <see cref="Task"/> representing the running operation</returns>
async Task RunWatchdog(string[] args, CancellationToken cancellationToken)
{
await watchdog.RunAsync(false, args, cancellationTokenSource.Token).ConfigureAwait(false);
await watchdog.RunAsync(false, args, cancellationToken).ConfigureAwait(false);
void StopServiceAsync()
{
@@ -41,6 +41,7 @@ namespace Tgstation.Server.Host.Service.Tests
cancellationToken = originalToken;
}
var cancelled = false;
mockWatchdog.Setup(x => x.RunAsync(false, args, It.IsAny<CancellationToken>())).Callback((bool x, string[] _, CancellationToken token) => token.Register(() => cancelled = true)).Returns(Task.CompletedTask).Verifiable();
var mockWatchdogFactory = new Mock<IWatchdogFactory>();
var mockLoggerFactory = new LoggerFactory();
@@ -48,11 +49,11 @@ namespace Tgstation.Server.Host.Service.Tests
using (var service = new ServerService(mockWatchdogFactory.Object, mockLoggerFactory, default))
{
Assert.IsFalse(cancelled);
onStart.Invoke(service, new object[] { args });
mockWatchdog.VerifyAll();
Assert.AreNotSame(cancellationToken, originalToken);
Assert.IsFalse(cancelled);
onStop.Invoke(service, Array.Empty<object>());
Assert.IsTrue(cancelled);