Reorganize tests by API and service concerns
This commit is contained in:
@@ -1,37 +1,10 @@
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using RpgRoller.Hosting;
|
||||
|
||||
namespace RpgRoller.Tests;
|
||||
|
||||
public sealed class BackendCoverageTests
|
||||
{
|
||||
[Fact]
|
||||
public void AddRpgRollerCore_WithInMemoryConnectionString_RegistersCoreServices()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.AddInMemoryCollection(new Dictionary<string, string?>
|
||||
{
|
||||
["ConnectionStrings:RpgRoller"] = "Data Source=:memory:"
|
||||
})
|
||||
.Build();
|
||||
|
||||
var environment = new TestWebHostEnvironment
|
||||
{
|
||||
ContentRootPath = Path.GetTempPath()
|
||||
};
|
||||
|
||||
services.AddRpgRollerCore(configuration, environment);
|
||||
|
||||
Assert.Contains(services, d => d.ServiceType == typeof(RpgRoller.Services.IGameService));
|
||||
Assert.Contains(services, d => d.ServiceType == typeof(RpgRoller.Services.IDiceRoller));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetRequiredSessionToken_ThrowsWhenTokenWasNotStored()
|
||||
{
|
||||
@@ -47,14 +20,4 @@ public sealed class BackendCoverageTests
|
||||
var exception = Assert.Throws<TargetInvocationException>(() => method!.Invoke(null, [context]));
|
||||
Assert.IsType<InvalidOperationException>(exception.InnerException);
|
||||
}
|
||||
|
||||
private sealed class TestWebHostEnvironment : IWebHostEnvironment
|
||||
{
|
||||
public string ApplicationName { get; set; } = "RpgRoller.Tests";
|
||||
public IFileProvider WebRootFileProvider { get; set; } = new NullFileProvider();
|
||||
public string WebRootPath { get; set; } = string.Empty;
|
||||
public string EnvironmentName { get; set; } = "Development";
|
||||
public string ContentRootPath { get; set; } = string.Empty;
|
||||
public IFileProvider ContentRootFileProvider { get; set; } = new NullFileProvider();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user