diff --git a/src/Tgstation.Server.Host.Console/Program.cs b/src/Tgstation.Server.Host.Console/Program.cs
index 0c8a1dc557..cf46d17f49 100644
--- a/src/Tgstation.Server.Host.Console/Program.cs
+++ b/src/Tgstation.Server.Host.Console/Program.cs
@@ -1,20 +1,27 @@
-using System.Threading.Tasks;
+using Microsoft.AspNetCore.Hosting;
+using System.Threading;
+using System.Threading.Tasks;
namespace Tgstation.Server.Host.Console
{
///
/// Contains the entrypoint for the application
///
- public static class Program
+ static class Program
{
+ ///
+ /// The for the
+ ///
+ internal static IServerFactory ServerFactory { get; set; } = new ServerFactory();
+
///
/// Entrypoint for the application
///
/// A representing the running operation
- public static Task Main()
+ internal static async Task Main()
{
- System.Console.WriteLine("Hello world!");
- return Task.CompletedTask;
+ using (var server = ServerFactory.CreateServer())
+ await server.RunAsync().ConfigureAwait(false);
}
}
}
diff --git a/src/Tgstation.Server.Host/AssemblyInfo.cs b/src/Tgstation.Server.Host/AssemblyInfo.cs
new file mode 100644
index 0000000000..d2a28919a4
--- /dev/null
+++ b/src/Tgstation.Server.Host/AssemblyInfo.cs
@@ -0,0 +1,3 @@
+using System.Runtime.CompilerServices;
+
+[assembly: InternalsVisibleTo("Tgstation.Server.Host.Tests")]
diff --git a/src/Tgstation.Server.Host/IServer.cs b/src/Tgstation.Server.Host/IServer.cs
new file mode 100644
index 0000000000..722f2f9e98
--- /dev/null
+++ b/src/Tgstation.Server.Host/IServer.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Tgstation.Server.Host
+{
+ ///
+ /// Represents the host
+ ///
+ public interface IServer : IDisposable
+ {
+ ///
+ /// Runs the
+ ///
+ /// A representing the running operation
+ Task RunAsync();
+ }
+}
diff --git a/src/Tgstation.Server.Host/IServerFactory.cs b/src/Tgstation.Server.Host/IServerFactory.cs
new file mode 100644
index 0000000000..7a5efbc7b2
--- /dev/null
+++ b/src/Tgstation.Server.Host/IServerFactory.cs
@@ -0,0 +1,14 @@
+namespace Tgstation.Server.Host
+{
+ ///
+ /// For creating s
+ ///
+ public interface IServerFactory
+ {
+ ///
+ /// Create a
+ ///
+ /// A new
+ IServer CreateServer();
+ }
+}
diff --git a/src/Tgstation.Server.Host/Server.cs b/src/Tgstation.Server.Host/Server.cs
new file mode 100644
index 0000000000..da98592c85
--- /dev/null
+++ b/src/Tgstation.Server.Host/Server.cs
@@ -0,0 +1,15 @@
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Tgstation.Server.Host
+{
+ ///
+ sealed class Server : IServer
+ {
+ ///
+ public void Dispose() { }
+
+ ///
+ public Task RunAsync() => Task.CompletedTask;
+ }
+}
diff --git a/src/Tgstation.Server.Host/ServerFactory.cs b/src/Tgstation.Server.Host/ServerFactory.cs
new file mode 100644
index 0000000000..d22e9938ee
--- /dev/null
+++ b/src/Tgstation.Server.Host/ServerFactory.cs
@@ -0,0 +1,9 @@
+namespace Tgstation.Server.Host
+{
+ ///
+ public sealed class ServerFactory : IServerFactory
+ {
+ ///
+ public IServer CreateServer() => new Server();
+ }
+}
diff --git a/tests/Tgstation.Server.Api.Tests/Tgstation.Server.Api.Tests.csproj b/tests/Tgstation.Server.Api.Tests/Tgstation.Server.Api.Tests.csproj
index 103f4472b1..e4e77805e2 100644
--- a/tests/Tgstation.Server.Api.Tests/Tgstation.Server.Api.Tests.csproj
+++ b/tests/Tgstation.Server.Api.Tests/Tgstation.Server.Api.Tests.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/tests/Tgstation.Server.Client.Tests/Tgstation.Server.Client.Tests.csproj b/tests/Tgstation.Server.Client.Tests/Tgstation.Server.Client.Tests.csproj
index 8061f3b7e8..caacb5743a 100644
--- a/tests/Tgstation.Server.Client.Tests/Tgstation.Server.Client.Tests.csproj
+++ b/tests/Tgstation.Server.Client.Tests/Tgstation.Server.Client.Tests.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/tests/Tgstation.Server.CommandLine.Tests/Tgstation.Server.CommandLine.Tests.csproj b/tests/Tgstation.Server.CommandLine.Tests/Tgstation.Server.CommandLine.Tests.csproj
index 46bbd02d4a..43a487525f 100644
--- a/tests/Tgstation.Server.CommandLine.Tests/Tgstation.Server.CommandLine.Tests.csproj
+++ b/tests/Tgstation.Server.CommandLine.Tests/Tgstation.Server.CommandLine.Tests.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/tests/Tgstation.Server.Host.Console.Tests/TestProgram.cs b/tests/Tgstation.Server.Host.Console.Tests/TestProgram.cs
index 9659a8dd16..1d089f6316 100644
--- a/tests/Tgstation.Server.Host.Console.Tests/TestProgram.cs
+++ b/tests/Tgstation.Server.Host.Console.Tests/TestProgram.cs
@@ -1,4 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Moq;
using System.Threading.Tasks;
namespace Tgstation.Server.Host.Console.Tests
@@ -9,7 +10,14 @@ namespace Tgstation.Server.Host.Console.Tests
[TestMethod]
public async Task TestProgramRuns()
{
+ var mockServer = new Mock();
+ mockServer.Setup(x => x.RunAsync()).Returns(Task.CompletedTask).Verifiable();
+ var mockServerFactory = new Mock();
+ mockServerFactory.Setup(x => x.CreateServer()).Returns(mockServer.Object).Verifiable();
+ Program.ServerFactory = mockServerFactory.Object;
await Program.Main().ConfigureAwait(false);
+ mockServer.VerifyAll();
+ mockServerFactory.VerifyAll();
}
}
}
diff --git a/tests/Tgstation.Server.Host.Console.Tests/Tgstation.Server.Host.Console.Tests.csproj b/tests/Tgstation.Server.Host.Console.Tests/Tgstation.Server.Host.Console.Tests.csproj
index 1234f45518..2e6e921228 100644
--- a/tests/Tgstation.Server.Host.Console.Tests/Tgstation.Server.Host.Console.Tests.csproj
+++ b/tests/Tgstation.Server.Host.Console.Tests/Tgstation.Server.Host.Console.Tests.csproj
@@ -8,7 +8,8 @@
-
+
+
diff --git a/tests/Tgstation.Server.Host.Tests/TestServer.cs b/tests/Tgstation.Server.Host.Tests/TestServer.cs
new file mode 100644
index 0000000000..4abee0c0a8
--- /dev/null
+++ b/tests/Tgstation.Server.Host.Tests/TestServer.cs
@@ -0,0 +1,16 @@
+using System.Threading.Tasks;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Tgstation.Server.Host.Tests
+{
+ [TestClass]
+ public sealed class TestServer
+ {
+ [TestMethod]
+ public async Task TestRunAndDispose()
+ {
+ using (var server = new Server())
+ await server.RunAsync().ConfigureAwait(false);
+ }
+ }
+}
diff --git a/tests/Tgstation.Server.Host.Tests/Tgstation.Server.Host.Tests.csproj b/tests/Tgstation.Server.Host.Tests/Tgstation.Server.Host.Tests.csproj
index 4f0518d744..f637b93ead 100644
--- a/tests/Tgstation.Server.Host.Tests/Tgstation.Server.Host.Tests.csproj
+++ b/tests/Tgstation.Server.Host.Tests/Tgstation.Server.Host.Tests.csproj
@@ -8,7 +8,7 @@
-
+