Added ability to order the execution of dictionary adapter behaviors.
[castle.git] / Experiments / Attic / Generator / Castle.ActiveRecord.Generator.Components.Tests / NamingServiceTestCase.cs
blobe0fe83e6f882a673f4cacbf38f5512b5480b840c
1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
2 //
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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
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.Generator.Components.Tests
17 using System;
19 using NUnit.Framework;
23 [TestFixture]
24 public class NamingServiceTestCase : AbstractContainerTestCase
26 [SetUp]
27 public void SetUpServices()
29 base.Init();
30 Kernel.AddComponent("namingservice", typeof(INamingService), typeof(NamingService));
33 [Test]
34 public void CreateClassName()
36 INamingService service = (INamingService) Kernel[ typeof(INamingService) ];
38 Assert.AreEqual( "Author", service.CreateClassName("authors") );
39 Assert.AreEqual( "Tax", service.CreateClassName("Taxes") );
40 Assert.AreEqual( "Child", service.CreateClassName("children") );
41 Assert.AreEqual( "Order", service.CreateClassName("Orders") );
42 Assert.AreEqual( "Order", service.CreateClassName("Order") );
43 Assert.AreEqual( "Order", service.CreateClassName("_Order") );
44 Assert.AreEqual( "Order", service.CreateClassName("tb_Order") );
45 Assert.AreEqual( "Order", service.CreateClassName("tb_Orders") );
48 [Test]
49 public void CreateFieldName()
51 INamingService service = (INamingService) Kernel[ typeof(INamingService) ];
53 Assert.AreEqual( "_orderName", service.CreateFieldName("order_name") );
54 Assert.AreEqual( "_name", service.CreateFieldName("name") );
55 Assert.AreEqual( "_customerName", service.CreateFieldName("customerName") );
56 Assert.AreEqual( "_customerName", service.CreateFieldName("customer_name") );
57 Assert.AreEqual( "_customerName", service.CreateFieldName("customer_Name") );
58 Assert.AreEqual( "_customerName", service.CreateFieldName("CustomerName") );
59 Assert.AreEqual( "_name", service.CreateFieldName("_name") );
62 [Test]
63 public void CreatePropertyName()
65 INamingService service = (INamingService) Kernel[ typeof(INamingService) ];
67 Assert.AreEqual( "OrderName", service.CreatePropertyName("order_name") );
68 Assert.AreEqual( "Name", service.CreatePropertyName("name") );
69 Assert.AreEqual( "CustomerName", service.CreatePropertyName("customerName") );
70 Assert.AreEqual( "CustomerName", service.CreatePropertyName("customer_Name") );
71 Assert.AreEqual( "CustomerName", service.CreatePropertyName("Customer_name") );
72 Assert.AreEqual( "Name", service.CreatePropertyName("_name") );
75 [Test]
76 public void CreateRelationName()
78 INamingService service = (INamingService) Kernel[ typeof(INamingService) ];
80 Assert.AreEqual( "Posts", service.CreateRelationName("Post") );
81 Assert.AreEqual( "Children", service.CreateRelationName("child") );
82 Assert.AreEqual( "Posts", service.CreateRelationName("posts") );
83 Assert.AreEqual( "Posts", service.CreateRelationName("post") );
84 Assert.AreEqual( "Orders", service.CreateRelationName("order") );
85 Assert.AreEqual( "Facilities", service.CreateRelationName("facility") );