1- using System . Collections . Generic ;
1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Diagnostics ;
4+ using System . IO ;
5+ using Efrpg ;
6+ using Efrpg . FileManagement ;
7+ using Efrpg . Filtering ;
8+ using Efrpg . Generators ;
9+ using Efrpg . Pluralization ;
10+ using Efrpg . Templates ;
11+ using NUnit . Framework ;
212
313namespace Generator . Tests . Integration
414{
5- using System ;
6- using System . Diagnostics ;
7- using System . IO ;
8- using Efrpg ;
9- using Efrpg . FileManagement ;
10- using Efrpg . Filtering ;
11- using Efrpg . Generators ;
12- using Efrpg . Pluralization ;
13- using Efrpg . Templates ;
14- using NUnit . Framework ;
15-
1615 public abstract class SingleDatabaseTestBase
1716 {
1817 protected static void SetupDatabase (
@@ -22,46 +21,45 @@ protected static void SetupDatabase(
2221 GeneratorType generatorType ,
2322 ForeignKeyNamingStrategy foreignKeyNamingStrategy )
2423 {
25- Settings . ForeignKeyNamingStrategy = foreignKeyNamingStrategy ;
26- Settings . TemplateType = templateType ;
27- Settings . GeneratorType = generatorType ;
28- Settings . ConnectionStringName = connectionStringName ;
29- Settings . DbContextName = dbContextName ;
30- Settings . GenerateSingleDbContext = true ;
24+ Settings . ForeignKeyNamingStrategy = foreignKeyNamingStrategy ;
25+ Settings . TemplateType = templateType ;
26+ Settings . GeneratorType = generatorType ;
27+ Settings . ConnectionStringName = connectionStringName ;
28+ Settings . DbContextName = dbContextName ;
29+ Settings . GenerateSingleDbContext = true ;
3130 Settings . MultiContextSettingsPlugin = null ;
32- Settings . Enumerations = null ;
33- Settings . PrependSchemaName = true ;
34- Settings . DisableGeographyTypes = false ;
35- Settings . AddUnitTestingDbContext = true ;
36- Settings . UsePascalCase = true ;
31+ Settings . Enumerations = null ;
32+ Settings . PrependSchemaName = true ;
33+ Settings . DisableGeographyTypes = false ;
34+ Settings . AddUnitTestingDbContext = true ;
35+ Settings . UsePascalCase = true ;
3736
3837 ResetFilters ( ) ;
3938 }
4039
41- protected static void Run ( string filename , string singleDbContextSubNamespace , Type fileManagerType , string subFolder , List < EnumDefinition > enumDefinitions = null )
40+ protected static void Run ( string filename , string singleDbContextSubNamespace , Type fileManagerType , string subFolder ,
41+ List < EnumDefinition > enumDefinitions = null )
4242 {
43- Inflector . PluralisationService = new EnglishPluralizationService ( ) ;
43+ Inflector . PluralisationService = new EnglishPluralizationService ( ) ;
4444 Settings . GenerateSingleDbContext = true ;
4545
4646 var path = Environment . GetFolderPath ( Environment . SpecialFolder . MyDocuments ) ;
4747 if ( ! string . IsNullOrEmpty ( subFolder ) )
4848 path = Path . Combine ( path , subFolder ) ;
49-
49+
5050 Settings . Root = path ;
5151 var fullPath = Path . Combine ( path , $ "{ filename } _{ Settings . DatabaseType } _{ Settings . TemplateType } _Fk{ Settings . ForeignKeyNamingStrategy } .cs") ;
52-
52+
5353 // Delete old generated files
5454 if ( File . Exists ( fullPath ) )
5555 File . Delete ( fullPath ) ;
5656 if ( ! string . IsNullOrEmpty ( subFolder ) )
57- {
5857 foreach ( var old in Directory . GetFiles ( Settings . Root ) )
5958 File . Delete ( old ) ;
60- }
6159
62- var outer = new GeneratedTextTransformation ( ) ;
60+ var outer = new GeneratedTextTransformation ( ) ;
6361 var fileManagement = new FileManagementService ( outer ) ;
64- var generator = GeneratorFactory . Create ( fileManagement , fileManagerType , singleDbContextSubNamespace ) ;
62+ var generator = GeneratorFactory . Create ( fileManagement , fileManagerType , singleDbContextSubNamespace ) ;
6563
6664 // Turn on everything for testing
6765 Assert . IsNotNull ( generator ) ;
@@ -70,19 +68,17 @@ protected static void Run(string filename, string singleDbContextSubNamespace, T
7068 Assert . IsNotNull ( filters ) ;
7169 foreach ( var filter in filters )
7270 {
73- filter . Value . IncludeViews = true ;
74- filter . Value . IncludeSynonyms = true ;
75- filter . Value . IncludeStoredProcedures = true ;
76- filter . Value . IncludeTableValuedFunctions = true ;
71+ filter . Value . IncludeViews = true ;
72+ filter . Value . IncludeSynonyms = true ;
73+ filter . Value . IncludeStoredProcedures = true ;
74+ filter . Value . IncludeTableValuedFunctions = true ;
7775 filter . Value . IncludeScalarValuedFunctions = true ;
7876
7977 if ( filter . Value is SingleContextFilter singleContextFilter )
80- {
8178 singleContextFilter . EnumDefinitions = enumDefinitions ;
82- }
8379 }
8480
85- var stopwatch = new Stopwatch ( ) ;
81+ var stopwatch = new Stopwatch ( ) ;
8682 var stopwatchGenerator = new Stopwatch ( ) ;
8783
8884 stopwatch . Start ( ) ;
@@ -94,17 +90,16 @@ protected static void Run(string filename, string singleDbContextSubNamespace, T
9490
9591 stopwatch . Stop ( ) ;
9692
97- Console . WriteLine ( "Duration: {0:F1} seconds, Generator {1:F1} seconds" , stopwatch . ElapsedMilliseconds / 1000.0 , stopwatchGenerator . ElapsedMilliseconds / 1000.0 ) ;
93+ Console . WriteLine ( "Duration: {0:F1} seconds, Generator {1:F1} seconds" , stopwatch . ElapsedMilliseconds / 1000.0 ,
94+ stopwatchGenerator . ElapsedMilliseconds / 1000.0 ) ;
9895 Console . WriteLine ( $ "Writing to { fullPath } ") ;
9996 Console . WriteLine ( ) ;
10097
10198 if ( outer . FileData . Length > 0 )
102- {
10399 using ( var sw = new StreamWriter ( fullPath ) )
104100 {
105101 sw . Write ( outer . FileData . ToString ( ) ) ;
106102 }
107- }
108103
109104 fileManagement . Process ( true ) ;
110105 }
@@ -125,10 +120,10 @@ protected static void CompareAgainstFolderTestComparison(string subFolder)
125120
126121 foreach ( var comparisonFile in testComparisonFiles )
127122 {
128- var filename = Path . GetFileName ( comparisonFile ) ;
129- var generatedPath = Path . Combine ( Settings . Root , filename ) ;
123+ var filename = Path . GetFileName ( comparisonFile ) ;
124+ var generatedPath = Path . Combine ( Settings . Root , filename ) ;
130125 var testComparison = File . ReadAllText ( comparisonFile ) ;
131- var generated = File . ReadAllText ( generatedPath ) ;
126+ var generated = File . ReadAllText ( generatedPath ) ;
132127
133128 Console . WriteLine ( comparisonFile ) ;
134129 Console . WriteLine ( generatedPath ) ;
@@ -140,12 +135,12 @@ protected static void CompareAgainstFolderTestComparison(string subFolder)
140135
141136 protected static void CompareAgainstTestComparison ( string database )
142137 {
143- var comparisonFile = $ "{ database } _{ Settings . DatabaseType } _{ Settings . TemplateType } _Fk{ Settings . ForeignKeyNamingStrategy } .cs";
144- var testRootPath = AppDomain . CurrentDomain . BaseDirectory ;
138+ var comparisonFile = $ "{ database } _{ Settings . DatabaseType } _{ Settings . TemplateType } _Fk{ Settings . ForeignKeyNamingStrategy } .cs";
139+ var testRootPath = AppDomain . CurrentDomain . BaseDirectory ;
145140 var testComparisonPath = Path . Combine ( testRootPath , $ "TestComparison\\ { comparisonFile } ") ;
146- var testComparison = File . ReadAllText ( testComparisonPath ) ;
147- var generatedPath = Path . Combine ( Settings . Root , comparisonFile ) ;
148- var generated = File . ReadAllText ( generatedPath ) ;
141+ var testComparison = File . ReadAllText ( testComparisonPath ) ;
142+ var generatedPath = Path . Combine ( Settings . Root , comparisonFile ) ;
143+ var generated = File . ReadAllText ( generatedPath ) ;
149144
150145 Console . WriteLine ( testComparisonPath ) ;
151146 Console . WriteLine ( generatedPath ) ;
0 commit comments