diff options
author | crupest <crupest@outlook.com> | 2020-10-31 00:42:06 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-31 00:42:06 +0800 |
commit | a3c97f6fb6313da2e8c0fac0b4c08f2ef4265d0f (patch) | |
tree | ee006874b0c93e9bfc76f141a092a8b9585a1f95 /Timeline.Tests/Helpers/TestApplication.cs | |
parent | 0c4caaebe2480e77918d5d7df234f0edaeab74ba (diff) | |
parent | 7ce0846d9ec968da3ea4f7ebcc6db26db8e49089 (diff) | |
download | timeline-a3c97f6fb6313da2e8c0fac0b4c08f2ef4265d0f.tar.gz timeline-a3c97f6fb6313da2e8c0fac0b4c08f2ef4265d0f.tar.bz2 timeline-a3c97f6fb6313da2e8c0fac0b4c08f2ef4265d0f.zip |
Merge pull request #161 from crupest/upgrade
Upgrade packages and split front end and back end.
Diffstat (limited to 'Timeline.Tests/Helpers/TestApplication.cs')
-rw-r--r-- | Timeline.Tests/Helpers/TestApplication.cs | 72 |
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();
- }
- }
-}
|