Ensure required property dependencies are satisifed before handler becomes valid
[castle.git] / ActiveRecord / Castle.ActiveRecord.Framework.Internal.Tests / ImportTestCase.cs
blob9bdfc0db8270eb9b58bb29d53671fff00addc2d1
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.Framework.Internal.Tests
17 using Castle.ActiveRecord.Framework.Internal.Tests.Model;
19 using NUnit.Framework;
21 [TestFixture]
22 public class ImportsTestCase : AbstractActiveRecordTest
24 [Test]
25 public void ImportsGeneration()
27 ActiveRecordModelBuilder builder = new ActiveRecordModelBuilder();
28 ActiveRecordModel model = builder.Create(typeof(ImportClass));
29 Assert.IsNotNull(model);
31 string xml = Process(builder, model);
33 string expected =
34 "<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n" +
35 "<hibernate-mapping auto-import=\"true\" default-lazy=\"false\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:nhibernate-mapping-2.2\">\r\n" +
36 " <import class=\"Castle.ActiveRecord.Framework.Internal.Tests.ImportClassRow, Castle.ActiveRecord.Framework.Internal.Tests\" rename=\"ImportClassRow\" />\r\n" +
37 " <class name=\"Castle.ActiveRecord.Framework.Internal.Tests.Model.ImportClass, Castle.ActiveRecord.Framework.Internal.Tests\" table=\"ImportClass\" lazy=\"false\">\r\n" +
38 " <id name=\"Id\" access=\"property\" column=\"Id\" type=\"Int32\" unsaved-value=\"0\">\r\n" +
39 " <generator class=\"native\">\r\n" +
40 " </generator>\r\n" +
41 " </id>\r\n" +
42 " <property name=\"Name\" access=\"property\" type=\"String\">\r\n" +
43 " <column name=\"Name\"/>\r\n" +
44 " </property>\r\n" +
45 " </class>\r\n" +
46 "</hibernate-mapping>\r\n";
48 Assert.AreEqual(expected, xml);
51 private string Process(ActiveRecordModelBuilder builder, ActiveRecordModel model)
53 GraphConnectorVisitor connectorVisitor = new
54 GraphConnectorVisitor(builder.Models);
55 connectorVisitor.VisitNode(model);
57 SemanticVerifierVisitor semanticVisitor = new
58 SemanticVerifierVisitor(builder.Models);
59 semanticVisitor.VisitNode(model);
61 XmlGenerationVisitor xmlVisitor = new XmlGenerationVisitor();
62 xmlVisitor.CreateXml(model);
64 return xmlVisitor.Xml;
68 public class ImportClassRow
71 public class ImportClassRow2