aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline.Tests/Helpers/TestDatabase.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-12-17 23:49:16 +0800
committerGitHub <noreply@github.com>2020-12-17 23:49:16 +0800
commit3b3c7c170f0070b0db85834b6c913b9060996d1d (patch)
treef5ce5a6ffebab52a4a990faa0d12937244cc3185 /BackEnd/Timeline.Tests/Helpers/TestDatabase.cs
parent828da7516df1a7612c3b24b4a27ba680eaf821f8 (diff)
parent5cbc306fc82bf14157ced4ff8b935191d20dae5d (diff)
downloadtimeline-3b3c7c170f0070b0db85834b6c913b9060996d1d.tar.gz
timeline-3b3c7c170f0070b0db85834b6c913b9060996d1d.tar.bz2
timeline-3b3c7c170f0070b0db85834b6c913b9060996d1d.zip
Merge pull request #192 from crupest/highlight-timeline
Highlight timeline.
Diffstat (limited to 'BackEnd/Timeline.Tests/Helpers/TestDatabase.cs')
-rw-r--r--BackEnd/Timeline.Tests/Helpers/TestDatabase.cs15
1 files changed, 10 insertions, 5 deletions
diff --git a/BackEnd/Timeline.Tests/Helpers/TestDatabase.cs b/BackEnd/Timeline.Tests/Helpers/TestDatabase.cs
index 74db74aa..00164835 100644
--- a/BackEnd/Timeline.Tests/Helpers/TestDatabase.cs
+++ b/BackEnd/Timeline.Tests/Helpers/TestDatabase.cs
@@ -1,11 +1,14 @@
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
+using System;
using System.Threading.Tasks;
using Timeline.Entities;
using Timeline.Migrations;
using Timeline.Services;
using Xunit;
+using Xunit.Abstractions;
namespace Timeline.Tests.Helpers
{
@@ -35,7 +38,7 @@ namespace Timeline.Tests.Helpers
if (_createUser)
{
var passwordService = new PasswordService();
- var userService = new UserService(NullLogger<UserService>.Instance, context, passwordService, new Clock(), new UserPermissionService(context));
+ var userService = new UserService(NullLogger<UserService>.Instance, context, passwordService, new UserPermissionService(context), new Clock());
var admin = await userService.CreateUser("admin", "adminpw");
await userService.ModifyUser(admin.Id, new ModifyUserParams() { Nickname = "administrator" });
@@ -54,12 +57,14 @@ namespace Timeline.Tests.Helpers
public SqliteConnection Connection { get; }
- public DatabaseContext CreateContext()
+ public DatabaseContext CreateContext(ITestOutputHelper? testOutputHelper = null)
{
- var options = new DbContextOptionsBuilder<DatabaseContext>()
- .UseSqlite(Connection).Options;
+ var optionsBuilder = new DbContextOptionsBuilder<DatabaseContext>()
+ .UseSqlite(Connection);
- return new DatabaseContext(options);
+ if (testOutputHelper != null) optionsBuilder.LogTo(testOutputHelper.WriteLine).EnableDetailedErrors().EnableSensitiveDataLogging();
+
+ return new DatabaseContext(optionsBuilder.Options);
}
}
}