diff --git a/src/Tgstation.Server.Host/Core/DBConnectionFactory.cs b/src/Tgstation.Server.Host/Core/DBConnectionFactory.cs
index 0b92cad465..8378d28d00 100644
--- a/src/Tgstation.Server.Host/Core/DBConnectionFactory.cs
+++ b/src/Tgstation.Server.Host/Core/DBConnectionFactory.cs
@@ -30,7 +30,7 @@ namespace Tgstation.Server.Host.Core
ConnectionString = connectionString
};
default:
- throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, "Invalid database type ({0})!", databaseType));
+ throw new ArgumentOutOfRangeException(nameof(databaseType), databaseType, "Invalid DatabaseType!");
}
}
}
diff --git a/src/Tgstation.Server.Host/IO/Console.cs b/src/Tgstation.Server.Host/IO/Console.cs
index 5c262b9f7e..7b8fce74b4 100644
--- a/src/Tgstation.Server.Host/IO/Console.cs
+++ b/src/Tgstation.Server.Host/IO/Console.cs
@@ -12,7 +12,7 @@ namespace Tgstation.Server.Host.IO
public bool Available => Environment.UserInteractive;
///
- public Task PressAnyKeyAsync(CancellationToken cancellationToken) => Task.Factory.StartNew(() => System.Console.ReadKey(), cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Current);
+ public Task PressAnyKeyAsync(CancellationToken cancellationToken) => Task.Factory.StartNew(() => System.Console.Read(), cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Current);
///
public Task ReadLineAsync(bool usePasswordChar, CancellationToken cancellationToken) => Task.Factory.StartNew(() =>
@@ -50,7 +50,13 @@ namespace Tgstation.Server.Host.IO
///
public Task WriteAsync(string text, bool newLine, CancellationToken cancellationToken) => Task.Factory.StartNew(() =>
{
- if (newLine)
+ if (text == null)
+ {
+ if (!newLine)
+ throw new InvalidOperationException("Cannot write null text without a new line!");
+ System.Console.WriteLine();
+ }
+ else if (newLine)
System.Console.WriteLine(text);
else
System.Console.Write(text);
diff --git a/tests/Tgstation.Server.Host.Tests/Core/DBConnectionFactoryTests.cs b/tests/Tgstation.Server.Host.Tests/Core/TestDBConnectionFactory.cs
similarity index 84%
rename from tests/Tgstation.Server.Host.Tests/Core/DBConnectionFactoryTests.cs
rename to tests/Tgstation.Server.Host.Tests/Core/TestDBConnectionFactory.cs
index f514ae3f07..39abca29bb 100644
--- a/tests/Tgstation.Server.Host.Tests/Core/DBConnectionFactoryTests.cs
+++ b/tests/Tgstation.Server.Host.Tests/Core/TestDBConnectionFactory.cs
@@ -7,14 +7,14 @@ using Tgstation.Server.Host.Configuration;
namespace Tgstation.Server.Host.Core.Tests
{
[TestClass]
- public sealed class DBConnectionFactoryTests
+ public sealed class TestDBConnectionFactory
{
[TestMethod]
public void TestBadParameters()
{
var factory = new DBConnectionFactory();
Assert.ThrowsException(() => factory.CreateConnection(null, default));
- Assert.ThrowsException(() => factory.CreateConnection(String.Empty, (DatabaseType)42));
+ Assert.ThrowsException(() => factory.CreateConnection(String.Empty, (DatabaseType)42));
}
[TestMethod]
diff --git a/tests/Tgstation.Server.Host.Tests/IO/TestConsole.cs b/tests/Tgstation.Server.Host.Tests/IO/TestConsole.cs
new file mode 100644
index 0000000000..d1a1ece5c2
--- /dev/null
+++ b/tests/Tgstation.Server.Host.Tests/IO/TestConsole.cs
@@ -0,0 +1,28 @@
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System;
+using System.IO;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Tgstation.Server.Host.IO.Tests
+{
+ [TestClass]
+ public sealed class TestConsole
+ {
+ [TestMethod]
+ public async Task TestWriteLine()
+ {
+ var console = new Console();
+ await Assert.ThrowsExceptionAsync(() => console.WriteAsync(null, false, default)).ConfigureAwait(false);
+ await console.WriteAsync(null, true, default).ConfigureAwait(false);
+ await console.WriteAsync(String.Empty, false, default).ConfigureAwait(true);
+ }
+
+ [TestMethod]
+ public void TestUserInteractive()
+ {
+ var console = new Console();
+ Assert.AreEqual(Environment.UserInteractive, console.Available);
+ }
+ }
+}