1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.ActiveRecord
.Tests
17 using Castle
.ActiveRecord
.Framework
.Config
;
18 using Castle
.ActiveRecord
.Framework
.Internal
;
19 using Castle
.ActiveRecord
.Tests
.Model
;
20 using NUnit
.Framework
;
23 public class PluralizationTestCase
: AbstractActiveRecordTest
26 public void PluralizationOn()
28 XmlConfigurationSource config
= (XmlConfigurationSource
) GetConfigSource();
29 config
.PluralizeTableNames
= true;
31 ActiveRecordStarter
.Initialize(config
, typeof(Post
), typeof(Blog
), typeof(Snippet
), typeof(Octopus
));
33 Assert
.AreEqual("PostTable", ActiveRecordModel
.GetModel(typeof(Post
)).ActiveRecordAtt
.Table
);
34 Assert
.AreEqual("BlogTable", ActiveRecordModel
.GetModel(typeof(Blog
)).ActiveRecordAtt
.Table
);
35 Assert
.AreEqual("Snippets", ActiveRecordModel
.GetModel(typeof(Snippet
)).ActiveRecordAtt
.Table
);
36 Assert
.AreEqual("Octopi", ActiveRecordModel
.GetModel(typeof(Octopus
)).ActiveRecordAtt
.Table
);
40 public void PluralizationOff()
42 XmlConfigurationSource config
= (XmlConfigurationSource
) GetConfigSource();
43 config
.PluralizeTableNames
= false;
45 ActiveRecordStarter
.Initialize(config
, typeof(Post
), typeof(Blog
), typeof(Snippet
), typeof(Octopus
));
47 Assert
.AreEqual("PostTable", ActiveRecordModel
.GetModel(typeof(Post
)).ActiveRecordAtt
.Table
);
48 Assert
.AreEqual("BlogTable", ActiveRecordModel
.GetModel(typeof(Blog
)).ActiveRecordAtt
.Table
);
49 Assert
.AreEqual("Snippet", ActiveRecordModel
.GetModel(typeof(Snippet
)).ActiveRecordAtt
.Table
);
50 Assert
.AreEqual("Octopus", ActiveRecordModel
.GetModel(typeof(Octopus
)).ActiveRecordAtt
.Table
);