Skip to content

Commit 97e933e

Browse files
committed
Adding logging to a test
1 parent 2de096b commit 97e933e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Test/UnitTests/TestDataLayer/TestPostgreSqlHelpers.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,13 @@ public void TestEnsureDeletedEnsureCreatedOk()
8181
public async Task TestEnsureCreatedAndEmptyPostgreSqlOk()
8282
{
8383
//SETUP
84-
var options = this.CreatePostgreSqlUniqueDatabaseOptions<BookContext>();
84+
var logOptions = new LogToOptions
85+
{
86+
ShowLog = false,
87+
LogLevel = Microsoft.Extensions.Logging.LogLevel.Debug,
88+
LoggerOptions = Microsoft.EntityFrameworkCore.Diagnostics.DbContextLoggerOptions.UtcTime
89+
};
90+
var options = this.CreatePostgreSqlUniqueClassOptionsWithLogTo<BookContext>(log => _output.WriteLine(log), logOptions);
8591
using (var context = new BookContext(options))
8692
{
8793
context.Database.EnsureCreated();
@@ -90,10 +96,12 @@ public async Task TestEnsureCreatedAndEmptyPostgreSqlOk()
9096
using (var context = new BookContext(options))
9197
{
9298
//ATTEMPT
99+
logOptions.ShowLog = true;
93100
using (new TimeThings(_output, "Time to empty database"))
94101
{
95102
await context.EnsureCreatedAndEmptyPostgreSqlAsync();
96103
}
104+
logOptions.ShowLog = false;
97105

98106
//VERIFY
99107
context.Books.Count().ShouldEqual(0);

0 commit comments

Comments
 (0)