From 3e5e6a0e24d01ef6e373171fe9952a3efb2d95fa Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Sun, 16 Sep 2018 11:19:10 -0400 Subject: [PATCH 1/3] Corrects IDreamDaemonClient.Start()'s return type --- src/Tgstation.Server.Client/Components/DreamDaemonClient.cs | 2 +- src/Tgstation.Server.Client/Components/IDreamDaemonClient.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Tgstation.Server.Client/Components/DreamDaemonClient.cs b/src/Tgstation.Server.Client/Components/DreamDaemonClient.cs index e0815a873b..10f72d0ffe 100644 --- a/src/Tgstation.Server.Client/Components/DreamDaemonClient.cs +++ b/src/Tgstation.Server.Client/Components/DreamDaemonClient.cs @@ -33,7 +33,7 @@ namespace Tgstation.Server.Client.Components public Task Shutdown(CancellationToken cancellationToken) => apiClient.Delete(Routes.DreamDaemon, instance.Id, cancellationToken); /// - public Task Start(CancellationToken cancellationToken) => apiClient.Create(Routes.DreamDaemon, instance.Id, cancellationToken); + public Task Start(CancellationToken cancellationToken) => apiClient.Create(Routes.DreamDaemon, instance.Id, cancellationToken); /// public Task Read(CancellationToken cancellationToken) => apiClient.Read(Routes.DreamDaemon, instance.Id, cancellationToken); diff --git a/src/Tgstation.Server.Client/Components/IDreamDaemonClient.cs b/src/Tgstation.Server.Client/Components/IDreamDaemonClient.cs index 0bb8a1d72b..764ddfbc23 100644 --- a/src/Tgstation.Server.Client/Components/IDreamDaemonClient.cs +++ b/src/Tgstation.Server.Client/Components/IDreamDaemonClient.cs @@ -21,7 +21,7 @@ namespace Tgstation.Server.Client.Components /// /// The for the operation /// A resulting in the information - Task Start(CancellationToken cancellationToken); + Task Start(CancellationToken cancellationToken); /// /// Shutdown From 76ebfd105e7f5e1339ed01ff3fb88f1c94ac4ae1 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Sun, 16 Sep 2018 11:19:38 -0400 Subject: [PATCH 2/3] Bump client preview version --- src/Tgstation.Server.Client/Tgstation.Server.Client.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj b/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj index 34cf1a89d8..054656e7df 100644 --- a/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj +++ b/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj @@ -3,7 +3,7 @@ netstandard2.0 Full - 4.0.0.0-preview9107 + 4.0.0.0-preview9108 true Cyberboss /tg/station 13 @@ -24,6 +24,7 @@ true bin\Release\netstandard2.0\Tgstation.Server.Client.xml + 0 From 676486683cb0f221ccb9cf0304bf4b82ffa3e43f Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Sun, 16 Sep 2018 11:25:38 -0400 Subject: [PATCH 3/3] Add another client test --- .../Components/TestDreamDaemonClient.cs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/Tgstation.Server.Client.Tests/Components/TestDreamDaemonClient.cs diff --git a/tests/Tgstation.Server.Client.Tests/Components/TestDreamDaemonClient.cs b/tests/Tgstation.Server.Client.Tests/Components/TestDreamDaemonClient.cs new file mode 100644 index 0000000000..a70423e97c --- /dev/null +++ b/tests/Tgstation.Server.Client.Tests/Components/TestDreamDaemonClient.cs @@ -0,0 +1,39 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Moq; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Tgstation.Server.Api; +using Tgstation.Server.Api.Models; + +namespace Tgstation.Server.Client.Components.Tests +{ + [TestClass] + public sealed class TestDreamDaemonClient + { + [TestMethod] + public async Task TestStart() + { + var example = new Job + { + Id = 347, + StartedAt = DateTimeOffset.Now + }; + + var inst = new Instance + { + Id = 4958 + }; + + var mockApiClient = new Mock(); + mockApiClient.Setup(x => x.Create(Routes.DreamDaemon, inst.Id, It.IsAny())).Returns(Task.FromResult(example)); + + var client = new DreamDaemonClient(mockApiClient.Object, inst); + + var result = await client.Start(default).ConfigureAwait(false); + Assert.AreSame(example, result); + } + } +}