From 9efbefec7b8d70fefb01d384cc22479c7ae73317 Mon Sep 17 00:00:00 2001 From: markrendle Date: Sun, 27 Nov 2011 21:02:27 +0000 Subject: [PATCH] Restored Pluralization test to BehaviourTests --- .../NameResolutionTests.cs | 38 +++++++++++++++++++ Simple.Data/MefHelper.cs | 1 - 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/Simple.Data.BehaviourTest/NameResolutionTests.cs b/Simple.Data.BehaviourTest/NameResolutionTests.cs index 2a825b91..1b426ab7 100644 --- a/Simple.Data.BehaviourTest/NameResolutionTests.cs +++ b/Simple.Data.BehaviourTest/NameResolutionTests.cs @@ -1,4 +1,5 @@ using System; +using System.Data.Entity.Design.PluralizationServices; using NUnit.Framework; using Simple.Data.Ado; using Simple.Data.Mocking.Ado; @@ -65,6 +66,43 @@ public void IndexerMethodWorksWithSchemaAndPluralFromSingular() GeneratedSqlIs("select [dbo].[Customers].[CustomerId] from [dbo].[Customers]"); } +#if(!MONO) + [Test] + public void CompaniesPluralizationIsResolved() + { + Database.SetPluralizer(new EntityPluralizer()); + _db.Companies.All().ToList(); + GeneratedSqlIs("select [dbo].[Company].[Id] from [dbo].[Company]"); + } + + class EntityPluralizer : IPluralizer + { + private readonly PluralizationService _pluralizationService = + PluralizationService.CreateService(CultureInfo.CurrentCulture); + + public bool IsPlural(string word) + { + return _pluralizationService.IsPlural(word); + } + + public bool IsSingular(string word) + { + return _pluralizationService.IsSingular(word); + } + + public string Pluralize(string word) + { + bool upper = (word.IsAllUpperCase()); + word = _pluralizationService.Pluralize(word); + return upper ? word.ToUpper(_pluralizationService.Culture) : word; + } + + public string Singularize(string word) + { + return _pluralizationService.Singularize(word); + } + } +#endif } [TestFixture] diff --git a/Simple.Data/MefHelper.cs b/Simple.Data/MefHelper.cs index cb1bc1f9..7b7e867a 100644 --- a/Simple.Data/MefHelper.cs +++ b/Simple.Data/MefHelper.cs @@ -76,7 +76,6 @@ private static CompositionContainer CreateContainer() var catalog = new AssemblyCatalog(file); aggregateCatalog.Catalogs.Add(catalog); } -// var folderCatalog = new DirectoryCatalog(path, "Simple.Data.*.dll"); return new CompositionContainer(aggregateCatalog); } }