diff options
author | crupest <crupest@outlook.com> | 2020-01-30 20:26:52 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-01-30 20:26:52 +0800 |
commit | 79ab2b304d93b1029515bd3f954db4e5a73f4168 (patch) | |
tree | 538ceea06640f501d2a950cac813c10561036e4d /Timeline.Tests/Helpers/TestApplication.cs | |
parent | dd0097af5c4ccbe25a1faca2286d729c93fd4116 (diff) | |
download | timeline-79ab2b304d93b1029515bd3f954db4e5a73f4168.tar.gz timeline-79ab2b304d93b1029515bd3f954db4e5a73f4168.tar.bz2 timeline-79ab2b304d93b1029515bd3f954db4e5a73f4168.zip |
...
Diffstat (limited to 'Timeline.Tests/Helpers/TestApplication.cs')
-rw-r--r-- | Timeline.Tests/Helpers/TestApplication.cs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/Timeline.Tests/Helpers/TestApplication.cs b/Timeline.Tests/Helpers/TestApplication.cs index d18f2848..14cafea3 100644 --- a/Timeline.Tests/Helpers/TestApplication.cs +++ b/Timeline.Tests/Helpers/TestApplication.cs @@ -1,4 +1,6 @@ using Microsoft.AspNetCore.Mvc.Testing;
+using Microsoft.AspNetCore.TestHost;
+using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using System;
@@ -8,19 +10,21 @@ namespace Timeline.Tests.Helpers {
public class TestApplication : IDisposable
{
- public TestDatabase Database { get; } = new TestDatabase();
+ public SqliteConnection DatabaseConnection { get; }
+
public WebApplicationFactory<Startup> Factory { get; }
public TestApplication(WebApplicationFactory<Startup> factory)
{
+ DatabaseConnection = new SqliteConnection("Data Source=:memory:;");
+
Factory = factory.WithWebHostBuilder(builder =>
{
- builder.ConfigureServices(services =>
+ builder.ConfigureTestServices(services =>
{
- services.AddEntityFrameworkSqlite();
services.AddDbContext<DatabaseContext, DevelopmentDatabaseContext>(options =>
{
- options.UseSqlite(Database.Connection);
+ options.UseSqlite(DatabaseConnection);
});
});
});
@@ -28,7 +32,8 @@ namespace Timeline.Tests.Helpers public void Dispose()
{
- Database.Dispose();
+ DatabaseConnection.Close();
+ DatabaseConnection.Dispose();
}
}
}
|