diff --git a/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj b/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj
index 32313ee50d..3b503feefc 100644
--- a/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj
+++ b/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj
@@ -2,7 +2,7 @@
- netstandard2.0
+ netstandard2.1
Full
true
Cyberboss
diff --git a/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj b/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj
index bad971af29..1a2c2fc98e 100644
--- a/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj
+++ b/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj
@@ -2,7 +2,7 @@
- netstandard2.0
+ netstandard2.1
Full
$(TgsClientVersion)
true
diff --git a/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj b/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj
index 5768a9e7ce..61236d1a8f 100644
--- a/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj
+++ b/src/Tgstation.Server.Host.Service/Tgstation.Server.Host.Service.csproj
@@ -3,7 +3,7 @@
Exe
- net471
+ net472
win
Full
$(TgsCoreVersion)
diff --git a/src/Tgstation.Server.Host/Controllers/RepositoryController.cs b/src/Tgstation.Server.Host/Controllers/RepositoryController.cs
index 69ebff6ea7..05b6804e55 100644
--- a/src/Tgstation.Server.Host/Controllers/RepositoryController.cs
+++ b/src/Tgstation.Server.Host/Controllers/RepositoryController.cs
@@ -80,6 +80,7 @@ namespace Tgstation.Server.Host.Controllers
var revisionInfo = await ApplyQuery(databaseContext.RevisionInformations).FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false);
+ // If the DB doesn't have it, check the local set
if (revisionInfo == default)
revisionInfo = databaseContext.RevisionInformations.Local.Where(x => x.CommitSha == repoSha && x.Instance.Id == instance.Id).FirstOrDefault();
@@ -669,6 +670,7 @@ namespace Tgstation.Server.Host.Controllers
var contextUser = databaseContext.Users.Local.Where(x => x.Id == AuthenticationContext.User.Id).FirstOrDefault();
if (contextUser == default)
{
+ // No reason to call the DB, just attach it
contextUser = new Models.User
{
Id = AuthenticationContext.User.Id
diff --git a/src/Tgstation.Server.Host/Core/Application.cs b/src/Tgstation.Server.Host/Core/Application.cs
index bb372eae36..3c8bffb668 100644
--- a/src/Tgstation.Server.Host/Core/Application.cs
+++ b/src/Tgstation.Server.Host/Core/Application.cs
@@ -5,7 +5,6 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Cors.Infrastructure;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@@ -67,9 +66,9 @@ namespace Tgstation.Server.Host.Core
readonly IIOManager ioManager;
///
- /// The for the
+ /// The for the
///
- readonly Microsoft.AspNetCore.Hosting.IHostingEnvironment hostingEnvironment;
+ readonly IWebHostEnvironment hostingEnvironment;
///
/// The used for determining when the is
@@ -91,7 +90,7 @@ namespace Tgstation.Server.Host.Core
public Application(
IConfiguration configuration,
IAssemblyInformationProvider assemblyInformationProvider,
- Microsoft.AspNetCore.Hosting.IHostingEnvironment hostingEnvironment,
+ IWebHostEnvironment hostingEnvironment,
IIOManager ioManager)
{
this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
@@ -146,11 +145,13 @@ namespace Tgstation.Server.Host.Core
// temporarily build the service provider in it's current state
// do it here so we can run the setup wizard if necessary
// also allows us to get some options and other services we need for continued configuration
+#pragma warning disable ASP0000 // Do not call 'IServiceCollection.BuildServiceProvider' in 'ConfigureServices'
using (var provider = services.BuildServiceProvider())
+#pragma warning restore ASP0000 // Do not call 'IServiceCollection.BuildServiceProvider' in 'ConfigureServices'
{
// run the wizard if necessary
var setupWizard = provider.GetRequiredService();
- var applicationLifetime = provider.GetRequiredService();
+ var applicationLifetime = provider.GetRequiredService();
var setupWizardRan = setupWizard.CheckRunWizard(applicationLifetime.ApplicationStopping).GetAwaiter().GetResult();
// load the configuration options we need
@@ -242,9 +243,11 @@ namespace Tgstation.Server.Host.Core
// add mvc, configure the json serializer settings
services
- .AddMvc()
- .SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
- .AddJsonOptions(options =>
+ .AddMvc(options =>
+ {
+ options.EnableEndpointRouting = false;
+ })
+ .AddNewtonsoftJson(options =>
{
options.AllowInputFormatterExceptionMessages = true;
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
diff --git a/src/Tgstation.Server.Host/Core/SetupWizard.cs b/src/Tgstation.Server.Host/Core/SetupWizard.cs
index 89f13a5016..afbbd5b3c7 100644
--- a/src/Tgstation.Server.Host/Core/SetupWizard.cs
+++ b/src/Tgstation.Server.Host/Core/SetupWizard.cs
@@ -36,9 +36,9 @@ namespace Tgstation.Server.Host.Core
readonly IConsole console;
///
- /// The for the
+ /// The for the
///
- readonly IHostingEnvironment hostingEnvironment;
+ readonly IWebHostEnvironment hostingEnvironment;
///
/// The for the
@@ -85,7 +85,7 @@ namespace Tgstation.Server.Host.Core
public SetupWizard(
IIOManager ioManager,
IConsole console,
- IHostingEnvironment hostingEnvironment,
+ IWebHostEnvironment hostingEnvironment,
IApplication application,
IDatabaseConnectionFactory dbConnectionFactory,
IPlatformIdentifier platformIdentifier,
diff --git a/src/Tgstation.Server.Host/Database/DatabaseCollection.cs b/src/Tgstation.Server.Host/Database/DatabaseCollection.cs
new file mode 100644
index 0000000000..c8c99996b5
--- /dev/null
+++ b/src/Tgstation.Server.Host/Database/DatabaseCollection.cs
@@ -0,0 +1,60 @@
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Linq.Expressions;
+
+namespace Tgstation.Server.Host.Database
+{
+ ///
+ sealed class DatabaseCollection : IDatabaseCollection where TModel : class
+ {
+ ///
+ /// The backing .
+ ///
+ readonly DbSet dbSet;
+
+ ///
+ /// Initializes a new instance of the .
+ ///
+ /// The value of .
+ public DatabaseCollection(DbSet dbSet)
+ {
+ this.dbSet = dbSet ?? throw new ArgumentNullException(nameof(dbSet));
+ }
+
+ ///
+ public IEnumerable Local => dbSet.Local;
+
+ ///
+ public Type ElementType => dbSet.AsQueryable().ElementType;
+
+ ///
+ public Expression Expression => dbSet.AsQueryable().Expression;
+
+ ///
+ public IQueryProvider Provider => dbSet.AsQueryable().Provider;
+
+ ///
+ public void Add(TModel model) => dbSet.Add(model);
+
+ ///
+ public void AddRange(IEnumerable models) => dbSet.AddRange(models);
+
+ ///
+ public void Attach(TModel model) => dbSet.Attach(model);
+
+ ///
+ public IEnumerator GetEnumerator() => dbSet.AsQueryable().GetEnumerator();
+
+ ///
+ public void Remove(TModel model) => dbSet.Remove(model);
+
+ ///
+ public void RemoveRange(IEnumerable models) => dbSet.RemoveRange(models);
+
+ ///
+ IEnumerator IEnumerable.GetEnumerator() => dbSet.AsQueryable().GetEnumerator();
+ }
+}
\ No newline at end of file
diff --git a/src/Tgstation.Server.Host/Database/DatabaseContext.cs b/src/Tgstation.Server.Host/Database/DatabaseContext.cs
index 86a75b4a77..d12fdb9ce5 100644
--- a/src/Tgstation.Server.Host/Database/DatabaseContext.cs
+++ b/src/Tgstation.Server.Host/Database/DatabaseContext.cs
@@ -19,43 +19,69 @@ namespace Tgstation.Server.Host.Database
#pragma warning disable CA1506 // TODO: Decomplexify
abstract class DatabaseContext : DbContext, IDatabaseContext where TParentContext : DbContext
{
- ///
+ ///
+ /// The s in the .
+ ///
public DbSet Users { get; set; }
- ///
+ ///
+ /// The s in the .
+ ///
public DbSet Instances { get; set; }
- ///
+ ///
+ /// The s in the .
+ ///
public DbSet CompileJobs { get; set; }
- ///
+ ///
+ /// The s in the .
+ ///
public DbSet RevisionInformations { get; set; }
- ///
+ ///
+ /// The in the .
+ ///
public DbSet DreamMakerSettings { get; set; }
- ///
+ ///
+ /// The s in the .
+ ///
public DbSet ChatBots { get; set; }
- ///
+ ///
+ /// The in the .
+ ///
public DbSet DreamDaemonSettings { get; set; }
- ///
+ ///
+ /// The in the .
+ ///
public DbSet RepositorySettings { get; set; }
- ///
+ ///
+ /// The s in the .
+ ///
public DbSet InstanceUsers { get; set; }
- ///
+ ///
+ /// The s in the .
+ ///
public DbSet ChatChannels { get; set; }
- ///
+ ///
+ /// The s in the .
+ ///
public DbSet Jobs { get; set; }
- ///
+ ///
+ /// The s in the .
+ ///
public DbSet ReattachInformations { get; set; }
- ///
+ ///
+ /// The s in the .
+ ///
public DbSet WatchdogReattachInformations { get; set; }
///
@@ -83,11 +109,115 @@ namespace Tgstation.Server.Host.Database
///
protected abstract DatabaseType DatabaseType { get; }
+ ///
+ IDatabaseCollection IDatabaseContext.Users => usersCollection;
+
+ ///
+ IDatabaseCollection IDatabaseContext.Instances => instancesCollection;
+
+ ///
+ IDatabaseCollection IDatabaseContext.InstanceUsers => instanceUsersCollection;
+
+ ///
+ IDatabaseCollection IDatabaseContext.Jobs => jobsCollection;
+
+ ///
+ IDatabaseCollection IDatabaseContext.CompileJobs => compileJobsCollection;
+
+ ///
+ IDatabaseCollection IDatabaseContext.RevisionInformations => revisionInformationsCollection;
+
+ ///
+ IDatabaseCollection IDatabaseContext.DreamMakerSettings => dreamMakerSettingsCollection;
+
+ ///
+ IDatabaseCollection IDatabaseContext.DreamDaemonSettings => dreamDaemonSettingsCollection;
+
+ ///
+ IDatabaseCollection IDatabaseContext.ChatBots => chatBotsCollection;
+
+ ///
+ IDatabaseCollection IDatabaseContext.ChatChannels => chatChannelsCollection;
+
+ ///
+ IDatabaseCollection IDatabaseContext.RepositorySettings => repositorySettingsCollection;
+
+ ///
+ IDatabaseCollection IDatabaseContext.ReattachInformations => reattachInformationsCollection;
+
+ ///
+ IDatabaseCollection IDatabaseContext.WatchdogReattachInformations => watchdogReattachInformationsCollection;
+
///
/// The for the
///
readonly IDatabaseSeeder databaseSeeder;
+ ///
+ /// Backing field for .
+ ///
+ readonly IDatabaseCollection usersCollection;
+
+ ///
+ /// Backing field for .
+ ///
+ readonly IDatabaseCollection instancesCollection;
+
+ ///
+ /// Backing field for .
+ ///
+ readonly IDatabaseCollection compileJobsCollection;
+
+ ///
+ /// Backing field for .
+ ///
+ readonly IDatabaseCollection instanceUsersCollection;
+
+ ///
+ /// Backing field for .
+ ///
+ readonly IDatabaseCollection jobsCollection;
+
+ ///
+ /// Backing field for .
+ ///
+ readonly IDatabaseCollection revisionInformationsCollection;
+
+ ///
+ /// Backing field for .
+ ///
+ readonly IDatabaseCollection dreamMakerSettingsCollection;
+
+ ///
+ /// Backing field for .
+ ///
+ readonly IDatabaseCollection dreamDaemonSettingsCollection;
+
+ ///
+ /// Backing field for .
+ ///
+ readonly IDatabaseCollection chatBotsCollection;
+
+ ///
+ /// Backing field for .
+ ///
+ readonly IDatabaseCollection chatChannelsCollection;
+
+ ///
+ /// Backing field for .
+ ///
+ readonly IDatabaseCollection repositorySettingsCollection;
+
+ ///
+ /// Backing field for .
+ ///
+ readonly IDatabaseCollection reattachInformationsCollection;
+
+ ///
+ /// Backing field for .
+ ///
+ readonly IDatabaseCollection watchdogReattachInformationsCollection;
+
///
/// Construct a
///
@@ -100,6 +230,20 @@ namespace Tgstation.Server.Host.Database
DatabaseConfiguration = databaseConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(databaseConfigurationOptions));
this.databaseSeeder = databaseSeeder ?? throw new ArgumentNullException(nameof(databaseSeeder));
Logger = logger ?? throw new ArgumentNullException(nameof(logger));
+
+ usersCollection = new DatabaseCollection(Users);
+ instancesCollection = new DatabaseCollection(Instances);
+ instanceUsersCollection = new DatabaseCollection(InstanceUsers);
+ compileJobsCollection = new DatabaseCollection(CompileJobs);
+ repositorySettingsCollection = new DatabaseCollection(RepositorySettings);
+ dreamMakerSettingsCollection = new DatabaseCollection(DreamMakerSettings);
+ dreamDaemonSettingsCollection = new DatabaseCollection(DreamDaemonSettings);
+ chatBotsCollection = new DatabaseCollection(ChatBots);
+ chatChannelsCollection = new DatabaseCollection(ChatChannels);
+ revisionInformationsCollection = new DatabaseCollection(RevisionInformations);
+ jobsCollection = new DatabaseCollection(Jobs);
+ reattachInformationsCollection = new DatabaseCollection(ReattachInformations);
+ watchdogReattachInformationsCollection = new DatabaseCollection(WatchdogReattachInformations);
}
///
@@ -166,7 +310,7 @@ namespace Tgstation.Server.Host.Database
else
Logger.LogDebug("No migrations to apply.");
- wasEmpty |= (await Users.CountAsync(cancellationToken).ConfigureAwait(false)) == 0;
+ wasEmpty |= (await Users.AsQueryable().CountAsync(cancellationToken).ConfigureAwait(false)) == 0;
if (wasEmpty)
{
diff --git a/src/Tgstation.Server.Host/Database/IDatabaseCollection.cs b/src/Tgstation.Server.Host/Database/IDatabaseCollection.cs
new file mode 100644
index 0000000000..52ca1796af
--- /dev/null
+++ b/src/Tgstation.Server.Host/Database/IDatabaseCollection.cs
@@ -0,0 +1,47 @@
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Tgstation.Server.Host.Database
+{
+ ///
+ /// Represents a database table.
+ ///
+ /// The type of model.
+ public interface IDatabaseCollection : IQueryable
+ {
+ ///
+ /// An of s prioritizing in the working set.
+ ///
+ IEnumerable Local { get; }
+
+ ///
+ /// Add a given to the the working set.
+ ///
+ /// The model to add.
+ void Add(TModel model);
+
+ ///
+ /// Remove a given from the the working set.
+ ///
+ /// The model to remove.
+ void Remove(TModel model);
+
+ ///
+ /// Attach a given to the the working set.
+ ///
+ /// The model to add.
+ void Attach(TModel model);
+
+ ///
+ /// Add a range of to the .
+ ///
+ /// An of s to add.
+ void AddRange(IEnumerable models);
+
+ ///
+ /// Remove a range of from the .
+ ///
+ /// An of s to remove.
+ void RemoveRange(IEnumerable models);
+ }
+}
diff --git a/src/Tgstation.Server.Host/Database/IDatabaseContext.cs b/src/Tgstation.Server.Host/Database/IDatabaseContext.cs
index a40113f5be..e0f0ad2e9f 100644
--- a/src/Tgstation.Server.Host/Database/IDatabaseContext.cs
+++ b/src/Tgstation.Server.Host/Database/IDatabaseContext.cs
@@ -14,67 +14,67 @@ namespace Tgstation.Server.Host.Database
///
/// The s in the
///
- DbSet Users { get; }
+ IDatabaseCollection Users { get; }
///
/// The s in the
///
- DbSet Instances { get; }
+ IDatabaseCollection Instances { get; }
///
/// The s in the
///
- DbSet InstanceUsers { get; }
+ IDatabaseCollection InstanceUsers { get; }
///
/// The s in the
///
- DbSet Jobs { get; }
+ IDatabaseCollection Jobs { get; }
///
/// The s in the
///
- DbSet CompileJobs { get; }
+ IDatabaseCollection CompileJobs { get; }
///
/// The s in the
///
- DbSet RevisionInformations { get; }
+ IDatabaseCollection RevisionInformations { get; }
///
/// The in the
///
- DbSet DreamMakerSettings { get; set; }
+ IDatabaseCollection DreamMakerSettings { get; }
///
/// The in the
///
- DbSet DreamDaemonSettings { get; set; }
+ IDatabaseCollection DreamDaemonSettings { get; }
///
/// The s in the
///
- DbSet ChatBots { get; set; }
+ IDatabaseCollection ChatBots { get; }
///
/// The in the
///
- DbSet ChatChannels { get; set; }
+ IDatabaseCollection ChatChannels { get; }
///
/// The in the
///
- DbSet RepositorySettings { get; set; }
+ IDatabaseCollection RepositorySettings { get; }
///
/// The for s
///
- DbSet ReattachInformations { get; set; }
+ IDatabaseCollection ReattachInformations { get; }
///
/// The for s
///
- DbSet WatchdogReattachInformations { get; set; }
+ IDatabaseCollection WatchdogReattachInformations { get; }
///
/// Saves changes made to the
diff --git a/src/Tgstation.Server.Host/Server.cs b/src/Tgstation.Server.Host/Server.cs
index a2fafe355d..5c95161b0d 100644
--- a/src/Tgstation.Server.Host/Server.cs
+++ b/src/Tgstation.Server.Host/Server.cs
@@ -1,5 +1,5 @@
-using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
@@ -26,9 +26,9 @@ namespace Tgstation.Server.Host
public bool WatchdogPresent => updatePath != null;
///
- /// The for the
+ /// The for the
///
- readonly IWebHostBuilder webHostBuilder;
+ readonly IHostBuilder hostBuilder;
///
/// The for the .
@@ -73,16 +73,16 @@ namespace Tgstation.Server.Host
///
/// Construct a
///
- /// The value of
+ /// The value of
/// The value of .
/// The value of
- public Server(IWebHostBuilder webHostBuilder, IIOManager ioManager, string updatePath)
+ public Server(IHostBuilder hostBuilder, IIOManager ioManager, string updatePath)
{
- this.webHostBuilder = webHostBuilder ?? throw new ArgumentNullException(nameof(webHostBuilder));
+ this.hostBuilder = hostBuilder ?? throw new ArgumentNullException(nameof(hostBuilder));
this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager));
this.updatePath = updatePath;
- webHostBuilder.ConfigureServices(serviceCollection => serviceCollection.AddSingleton(this));
+ hostBuilder.ConfigureServices(serviceCollection => serviceCollection.AddSingleton(this));
restartHandlers = new List();
}
@@ -129,15 +129,15 @@ namespace Tgstation.Server.Host
fsWatcher.EnableRaisingEvents = true;
}
- using (var webHost = webHostBuilder.Build())
+ using (var host = hostBuilder.Build())
try
{
- logger = webHost.Services.GetRequiredService>();
+ logger = host.Services.GetRequiredService>();
using (cancellationToken.Register(() => logger.LogInformation("Process termination requested!")))
{
- var generalConfigurationOptions = webHost.Services.GetRequiredService>();
+ var generalConfigurationOptions = host.Services.GetRequiredService>();
generalConfiguration = generalConfigurationOptions.Value;
- await webHost.RunAsync(cancellationTokenSource.Token).ConfigureAwait(false);
+ await host.RunAsync(cancellationTokenSource.Token).ConfigureAwait(false);
}
}
catch (OperationCanceledException)
diff --git a/src/Tgstation.Server.Host/ServerFactory.cs b/src/Tgstation.Server.Host/ServerFactory.cs
index 9013b8a206..310d5e0b12 100644
--- a/src/Tgstation.Server.Host/ServerFactory.cs
+++ b/src/Tgstation.Server.Host/ServerFactory.cs
@@ -1,7 +1,7 @@
-using Microsoft.AspNetCore;
-using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
using System;
using System.IO;
using Tgstation.Server.Host.Core;
@@ -44,21 +44,26 @@ namespace Tgstation.Server.Host
///
public IServer CreateServer(string[] args, string updatePath)
{
- var webHost = WebHost.CreateDefaultBuilder(args ?? throw new ArgumentNullException(nameof(args)))
+ var hostBuilder = Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(
+ args ?? throw new ArgumentNullException(nameof(args)))
.ConfigureAppConfiguration((context, configurationBuilder) => configurationBuilder.SetBasePath(Directory.GetCurrentDirectory()))
.ConfigureServices(serviceCollection =>
{
serviceCollection.AddSingleton(IOManager);
serviceCollection.AddSingleton(assemblyInformationProvider);
})
- .UseStartup()
- .SuppressStatusMessages(true)
- .UseShutdownTimeout(TimeSpan.FromMinutes(1));
+ .ConfigureWebHostDefaults(webHostBuilder =>
+ {
+ webHostBuilder
+ .UseStartup()
+ .SuppressStatusMessages(true)
+ .UseShutdownTimeout(TimeSpan.FromMinutes(1));
+ });
if(updatePath != null)
- webHost.UseContentRoot(Path.GetDirectoryName(assemblyInformationProvider.Path));
+ hostBuilder.UseContentRoot(Path.GetDirectoryName(assemblyInformationProvider.Path));
- return new Server(webHost, IOManager, updatePath);
+ return new Server(hostBuilder, IOManager, updatePath);
}
}
}
diff --git a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj
index 9a698abb91..d69f390ec4 100644
--- a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj
+++ b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj
@@ -2,22 +2,24 @@
- netcoreapp2.2
+ netcoreapp3.1
Full
$(TgsCoreVersion)
latest
../../build/analyzers.ruleset
false
+ true
true
bin\Release\netcoreapp2.1\Tgstation.Server.Host.xml
+ API1000
- 1701;1702;SA1652;CA1063
+ API1000
bin\Debug\netcoreapp2.1\Tgstation.Server.Host.xml
@@ -49,27 +51,27 @@
-
-
-
-
-
+
+
all
runtime; build; native; contentfiles; analyzers
-
-
-
-
-
+
+
all
- runtime; build; native; contentfiles; analyzers
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
-
@@ -79,11 +81,11 @@
-
+
-
+
diff --git a/tests/Tgstation.Server.Host.Service.Tests/Tgstation.Server.Host.Service.Tests.csproj b/tests/Tgstation.Server.Host.Service.Tests/Tgstation.Server.Host.Service.Tests.csproj
index 289ae70367..ef9f3cd8b2 100644
--- a/tests/Tgstation.Server.Host.Service.Tests/Tgstation.Server.Host.Service.Tests.csproj
+++ b/tests/Tgstation.Server.Host.Service.Tests/Tgstation.Server.Host.Service.Tests.csproj
@@ -1,7 +1,7 @@
- net471
+ net472
false
latest
diff --git a/tests/Tgstation.Server.Host.Tests/Core/TestApplication.cs b/tests/Tgstation.Server.Host.Tests/Core/TestApplication.cs
index fd19fd0ae9..d924170aaf 100644
--- a/tests/Tgstation.Server.Host.Tests/Core/TestApplication.cs
+++ b/tests/Tgstation.Server.Host.Tests/Core/TestApplication.cs
@@ -1,12 +1,11 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using System;
-using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Tgstation.Server.Host.Configuration;
@@ -34,7 +33,7 @@ namespace Tgstation.Server.Host.Core.Tests
Assert.ThrowsException(() => new Application(mockConfiguration.Object, mockAssemblyInfo.Object, null, null));
- var mockHostingEnvironment = new Mock();
+ var mockHostingEnvironment = new Mock();
Assert.ThrowsException(() => new Application(mockConfiguration.Object, mockAssemblyInfo.Object, mockHostingEnvironment.Object, null));
var app = new Application(mockConfiguration.Object, mockAssemblyInfo.Object, mockHostingEnvironment.Object, Mock.Of());
@@ -67,7 +66,7 @@ namespace Tgstation.Server.Host.Core.Tests
public Task CheckRunWizard(CancellationToken cancellationToken) => Task.FromResult(true);
}
- class MockApplicationLifetime : IApplicationLifetime
+ class MockHostApplicationLifetime : IHostApplicationLifetime
{
public CancellationToken ApplicationStarted => default;
@@ -77,42 +76,5 @@ namespace Tgstation.Server.Host.Core.Tests
public void StopApplication() { }
}
-
- [TestMethod]
- public void TestConfigureServicesThrowsWhenSetupWizardConfigurationDemands()
- {
- var mockConfiguration = new Mock();
- var mockAssemblyInfo = new Mock();
- mockAssemblyInfo.SetupGet(x => x.Name).Returns(typeof(Application).Assembly.GetName());
- var mockHostingEnvironment = new Mock();
-
- var app = new Application(mockConfiguration.Object, mockAssemblyInfo.Object, mockHostingEnvironment.Object, Mock.Of());
-
- var mockOptions = new Mock>();
- mockOptions.SetupGet(x => x.Value).Returns(new GeneralConfiguration
- {
- SetupWizardMode = SetupWizardMode.Only
- }).Verifiable();
-
- var fakeServiceDescriptor = new List()
- {
- new ServiceDescriptor(typeof(IApplicationLifetime), typeof(MockApplicationLifetime), ServiceLifetime.Singleton),
- new ServiceDescriptor(typeof(ISetupWizard), typeof(MockSetupWizard), ServiceLifetime.Singleton),
- new ServiceDescriptor(typeof(IOptions), mockOptions.Object)
- };
-
- var mockServiceCollection = new Mock();
-
- var mockConfigSection = new Mock();
-
- mockConfiguration.Setup(x => x.GetSection(It.IsNotNull())).Returns(mockConfigSection.Object).Verifiable();
- mockServiceCollection.Setup(x => x.GetEnumerator()).Returns(() => fakeServiceDescriptor.GetEnumerator()).Verifiable();
-
- Assert.ThrowsException(() => app.ConfigureServices(mockServiceCollection.Object));
-
- mockOptions.VerifyAll();
- mockConfiguration.VerifyAll();
- mockServiceCollection.VerifyAll();
- }
}
}
diff --git a/tests/Tgstation.Server.Host.Tests/Core/TestSetupWizard.cs b/tests/Tgstation.Server.Host.Tests/Core/TestSetupWizard.cs
index 04fd715b31..f6548f3abe 100644
--- a/tests/Tgstation.Server.Host.Tests/Core/TestSetupWizard.cs
+++ b/tests/Tgstation.Server.Host.Tests/Core/TestSetupWizard.cs
@@ -28,7 +28,7 @@ namespace Tgstation.Server.Host.Core.Tests
Assert.ThrowsException(() => new SetupWizard(mockIOManager.Object, null, null, null, null, null, null, null, null));
var mockConsole = new Mock();
Assert.ThrowsException(() => new SetupWizard(mockIOManager.Object, mockConsole.Object, null, null, null, null, null, null, null));
- var mockHostingEnvironment = new Mock();
+ var mockHostingEnvironment = new Mock();
Assert.ThrowsException(() => new SetupWizard(mockIOManager.Object, mockConsole.Object, mockHostingEnvironment.Object, null, null, null, null, null, null));
var mockApplication = new Mock();
Assert.ThrowsException(() => new SetupWizard(mockIOManager.Object, mockConsole.Object, mockHostingEnvironment.Object, mockApplication.Object, null, null, null, null, null));
@@ -47,7 +47,7 @@ namespace Tgstation.Server.Host.Core.Tests
{
var mockIOManager = new Mock();
var mockConsole = new Mock();
- var mockHostingEnvironment = new Mock();
+ var mockHostingEnvironment = new Mock();
var mockApplication = new Mock();
var mockDBConnectionFactory = new Mock();
var mockLogger = new Mock>();
@@ -76,7 +76,7 @@ namespace Tgstation.Server.Host.Core.Tests
mockConsole.SetupGet(x => x.Available).Returns(true).Verifiable();
mockIOManager.Setup(x => x.FileExists(It.IsNotNull(), It.IsAny())).Returns(Task.FromResult(true)).Verifiable();
- mockIOManager.Setup(x => x.ReadAllBytes(It.IsNotNull(), It.IsAny())).Returns(Task.FromResult(Encoding.UTF8.GetBytes("cucked"))).Verifiable();
+ mockIOManager.Setup(x => x.ReadAllBytes(It.IsNotNull(), It.IsAny())).Returns(Task.FromResult(Encoding.UTF8.GetBytes("less profane"))).Verifiable();
mockIOManager.Setup(x => x.WriteAllBytes(It.IsNotNull(), It.IsNotNull(), It.IsAny())).Returns(Task.CompletedTask).Verifiable();
var mockSuccessCommand = new Mock();
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 e68421039f..08e93cbdf7 100644
--- a/tests/Tgstation.Server.Host.Tests/Tgstation.Server.Host.Tests.csproj
+++ b/tests/Tgstation.Server.Host.Tests/Tgstation.Server.Host.Tests.csproj
@@ -1,7 +1,7 @@
- netcoreapp2.2
+ netcoreapp3.1
false
latest
diff --git a/tests/Tgstation.Server.Tests/Tgstation.Server.Tests.csproj b/tests/Tgstation.Server.Tests/Tgstation.Server.Tests.csproj
index 726ec61319..35b5223cf1 100644
--- a/tests/Tgstation.Server.Tests/Tgstation.Server.Tests.csproj
+++ b/tests/Tgstation.Server.Tests/Tgstation.Server.Tests.csproj
@@ -1,7 +1,7 @@
- netcoreapp2.2
+ netcoreapp3.1
false
latest