File tree Expand file tree Collapse file tree
Simple.Data.BehaviourTest Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using System ;
2+ using System . Data . Entity . Design . PluralizationServices ;
23using NUnit . Framework ;
34using Simple . Data . Ado ;
45using Simple . Data . Mocking . Ado ;
@@ -65,6 +66,43 @@ public void IndexerMethodWorksWithSchemaAndPluralFromSingular()
6566 GeneratedSqlIs ( "select [dbo].[Customers].[CustomerId] from [dbo].[Customers]" ) ;
6667 }
6768
69+ #if( ! MONO )
70+ [ Test ]
71+ public void CompaniesPluralizationIsResolved ( )
72+ {
73+ Database . SetPluralizer ( new EntityPluralizer ( ) ) ;
74+ _db . Companies . All ( ) . ToList ( ) ;
75+ GeneratedSqlIs ( "select [dbo].[Company].[Id] from [dbo].[Company]" ) ;
76+ }
77+
78+ class EntityPluralizer : IPluralizer
79+ {
80+ private readonly PluralizationService _pluralizationService =
81+ PluralizationService . CreateService ( CultureInfo . CurrentCulture ) ;
82+
83+ public bool IsPlural ( string word )
84+ {
85+ return _pluralizationService . IsPlural ( word ) ;
86+ }
87+
88+ public bool IsSingular ( string word )
89+ {
90+ return _pluralizationService . IsSingular ( word ) ;
91+ }
92+
93+ public string Pluralize ( string word )
94+ {
95+ bool upper = ( word . IsAllUpperCase ( ) ) ;
96+ word = _pluralizationService . Pluralize ( word ) ;
97+ return upper ? word . ToUpper ( _pluralizationService . Culture ) : word ;
98+ }
99+
100+ public string Singularize ( string word )
101+ {
102+ return _pluralizationService . Singularize ( word ) ;
103+ }
104+ }
105+ #endif
68106 }
69107
70108 [ TestFixture ]
Original file line number Diff line number Diff line change @@ -76,7 +76,6 @@ private static CompositionContainer CreateContainer()
7676 var catalog = new AssemblyCatalog ( file ) ;
7777 aggregateCatalog . Catalogs . Add ( catalog ) ;
7878 }
79- // var folderCatalog = new DirectoryCatalog(path, "Simple.Data.*.dll");
8079 return new CompositionContainer ( aggregateCatalog ) ;
8180 }
8281 }
You can’t perform that action at this time.
0 commit comments