aboutsummaryrefslogtreecommitdiff
path: root/Timeline.Tests/Helpers/TestApplication.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-10-27 19:21:35 +0800
committercrupest <crupest@outlook.com>2020-10-27 19:21:35 +0800
commitac769e656b122ff569c3f1534701b71e00fed586 (patch)
tree72966645ff1e25139d3995262e1c4349f2c14733 /Timeline.Tests/Helpers/TestApplication.cs
parent14e5848c23c643cea9b5d709770747d98c3d75e2 (diff)
downloadtimeline-ac769e656b122ff569c3f1534701b71e00fed586.tar.gz
timeline-ac769e656b122ff569c3f1534701b71e00fed586.tar.bz2
timeline-ac769e656b122ff569c3f1534701b71e00fed586.zip
Split front and back end.
Diffstat (limited to 'Timeline.Tests/Helpers/TestApplication.cs')
-rw-r--r--Timeline.Tests/Helpers/TestApplication.cs72
1 files changed, 0 insertions, 72 deletions
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<string, string>
- {
- [ApplicationConfiguration.UseMockFrontEndKey] = "true",
- ["WorkDir"] = WorkDir
- });
- })
- .ConfigureServices(services =>
- {
- services.AddDbContext<DatabaseContext>(options =>
- {
- options.UseSqlite(Database.Connection);
- });
- })
- .ConfigureWebHost(webBuilder =>
- {
- webBuilder
- .UseTestServer()
- .UseStartup<Startup>();
- })
- .StartAsync();
- }
-
- public async Task DisposeAsync()
- {
- await Host.StopAsync();
- Host.Dispose();
-
- Directory.Delete(WorkDir, true);
-
- await Database.DisposeAsync();
- }
- }
-}