From ac769e656b122ff569c3f1534701b71e00fed586 Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 27 Oct 2020 19:21:35 +0800 Subject: Split front and back end. --- Timeline.Tests/Helpers/TestApplication.cs | 72 ------------------------------- 1 file changed, 72 deletions(-) delete mode 100644 Timeline.Tests/Helpers/TestApplication.cs (limited to 'Timeline.Tests/Helpers/TestApplication.cs') diff --git a/Timeline.Tests/Helpers/TestApplication.cs b/Timeline.Tests/Helpers/TestApplication.cs deleted file mode 100644 index 684ffe2c..00000000 --- a/Timeline.Tests/Helpers/TestApplication.cs +++ /dev/null @@ -1,72 +0,0 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.TestHost; -using Microsoft.Data.Sqlite; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using System.Collections.Generic; -using System.IO; -using System.Threading.Tasks; -using Timeline.Configs; -using Timeline.Entities; -using Xunit; - -namespace Timeline.Tests.Helpers -{ - public class TestApplication : IAsyncLifetime - { - public TestDatabase Database { get; } - - public IHost Host { get; private set; } - - public string WorkDir { get; private set; } - - public TestApplication() - { - Database = new TestDatabase(false); - } - - public async Task InitializeAsync() - { - await Database.InitializeAsync(); - - WorkDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); - Directory.CreateDirectory(WorkDir); - - Host = await Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder() - .ConfigureAppConfiguration((context, config) => - { - config.AddInMemoryCollection(new Dictionary - { - [ApplicationConfiguration.UseMockFrontEndKey] = "true", - ["WorkDir"] = WorkDir - }); - }) - .ConfigureServices(services => - { - services.AddDbContext(options => - { - options.UseSqlite(Database.Connection); - }); - }) - .ConfigureWebHost(webBuilder => - { - webBuilder - .UseTestServer() - .UseStartup(); - }) - .StartAsync(); - } - - public async Task DisposeAsync() - { - await Host.StopAsync(); - Host.Dispose(); - - Directory.Delete(WorkDir, true); - - await Database.DisposeAsync(); - } - } -} -- cgit v1.2.3