Added RedirectUsingNamedRoute
[castle.git] / ActiveRecord / Castle.ActiveRecord.Tests / CompositeNestedClassTestCase.cs
blobd019ca08fd08b15aa36402c7ee5241a7ebf462c2
1 // Copyright 2004-2008 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.Tests
17 using System;
18 using Castle.ActiveRecord.Tests.Model.CompositeNested;
19 using NUnit.Framework;
22 [TestFixture]
23 public class CompositeNestedClassTestCase : AbstractActiveRecordTest
25 [Test]
26 public void CompositeNestedComponents()
28 ActiveRecordStarter.Initialize( GetConfigSource(),
29 typeof(CompositeNestedParent), typeof(NestedDependent),
30 typeof(Dependent));
31 Recreate();
33 CompositeNestedParent.DeleteAll();
35 CompositeNestedParent compositeNestedParent = new CompositeNestedParent();
36 compositeNestedParent.Save();
38 compositeNestedParent = CompositeNestedParent.Find(compositeNestedParent.Id);
40 Assert.AreEqual(1, compositeNestedParent.Id);
41 Assert.IsNotNull(compositeNestedParent.Dependents);
43 Dependent dependent = new Dependent();
44 dependent.NestedDependentProp = new NestedDependent();
45 dependent.NestedDependentProp.IntProp = 1;
46 dependent.DateProp = new DateTime(2000, 1, 1);
48 dependent.NestedDependentProp.InnerNestedDependantProp = new InnerNestedDependant();
49 dependent.NestedDependentProp.InnerNestedDependantProp.StringProp = "String property value";
51 compositeNestedParent.Dependents.Add(dependent);
53 compositeNestedParent.Save();
55 compositeNestedParent = CompositeNestedParent.Find(compositeNestedParent.Id);
57 Assert.AreEqual(1, compositeNestedParent.Dependents.Count);
58 dependent = (Dependent) compositeNestedParent.Dependents[0];
60 Assert.AreEqual(1, dependent.NestedDependentProp.IntProp);
61 Assert.AreEqual("String property value", dependent.NestedDependentProp.InnerNestedDependantProp.StringProp);