1+ // Copyright (c) 2020 Jon P Smith, GitHub: JonPSmith, web: http://www.thereformedprogrammer.net/
2+ // Licensed under MIT license. See License.txt in the project root for license information.
3+
4+ using System . Collections . Generic ;
5+ using System . Linq ;
6+ using System . Threading . Tasks ;
7+ using DataLayer . BookApp . EfCode ;
8+ using DataLayer . LargeDatabase ;
9+ using Microsoft . EntityFrameworkCore ;
10+ using Npgsql ;
11+ using Test . Helpers ;
12+ using TestSupport . Attributes ;
13+ using TestSupport . EfHelpers ;
14+ using Xunit ;
15+ using Xunit . Abstractions ;
16+ using Xunit . Extensions . AssertExtensions ;
17+
18+ namespace Test . UnitTests . TestDataLayer
19+ {
20+ public class TestPostgreSqlLargeDatabasePerformance
21+ {
22+ private readonly ITestOutputHelper _output ;
23+
24+ public TestPostgreSqlLargeDatabasePerformance ( ITestOutputHelper output )
25+ {
26+ _output = output ;
27+ }
28+
29+ [ Fact ]
30+ public void TestLargeDbEnsureDeletedEnsureCreatedOk ( )
31+ {
32+ //SETUP
33+ var options = this . CreatePostgreSqlUniqueDatabaseOptions < LargeDbContext > ( ) ;
34+ using var context = new LargeDbContext ( options ) ;
35+
36+ context . Database . EnsureCreated ( ) ;
37+
38+ //ATTEMPT
39+ using ( new TimeThings ( _output , "LargeDatabase to EnsureDeleted and EnsureCreated" ) )
40+ {
41+ context . Database . EnsureDeleted ( ) ;
42+ context . Database . EnsureCreated ( ) ;
43+ }
44+
45+ //VERIFY
46+ }
47+
48+
49+ [ Fact ]
50+ public void TestLargeDbEnsureCleanExistingDatabaseOk ( )
51+ {
52+ //SETUP
53+ var options = this . CreatePostgreSqlUniqueDatabaseOptions < LargeDbContext > ( ) ;
54+ using var context = new LargeDbContext ( options ) ;
55+
56+ context . Database . EnsureCreated ( ) ;
57+
58+ //ATTEMPT
59+ using ( new TimeThings ( _output , "LargeDatabase to EnsureClean" ) )
60+ {
61+ context . Database . EnsureClean ( ) ;
62+ }
63+
64+ //VERIFY
65+ }
66+
67+ [ Fact ]
68+ public async Task TestLargeDbEnsureCreatedAndEmptyPostgreSqlOk ( )
69+ {
70+ //SETUP
71+ var options = this . CreatePostgreSqlUniqueDatabaseOptions < LargeDbContext > ( ) ;
72+ using var context = new LargeDbContext ( options ) ;
73+
74+ context . Database . EnsureCreated ( ) ;
75+
76+ //ATTEMPT
77+ using ( new TimeThings ( _output , "LargeDatabase to empty database" ) )
78+ {
79+ await context . EnsureCreatedAndEmptyPostgreSqlAsync ( ) ;
80+ }
81+
82+ //VERIFY
83+ }
84+ }
85+ }
0 commit comments