Added RedirectUsingNamedRoute
[castle.git] / ActiveRecord / Castle.ActiveRecord.Tests / JoinedSubClassTestCase.cs
blobdb5a884671464ca5dc3c6dc35d192f15ca0c1b85
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 NUnit.Framework;
19 using Castle.ActiveRecord.Tests.Model;
21 [TestFixture]
22 public class JoinedSubClassTestCase : AbstractActiveRecordTest
24 [Test]
25 public void Entities()
27 ActiveRecordStarter.Initialize( GetConfigSource(),
28 typeof(Entity), typeof(CompanyEntity), typeof(PersonEntity) );
29 Recreate();
31 Entity.DeleteAll();
32 CompanyEntity.DeleteAll();
33 PersonEntity.DeleteAll();
35 Entity ent = new Entity();
36 ent.Name = "MS";
37 ent.Save();
39 CompanyEntity ce = new CompanyEntity();
40 ce.Name = "Keldor";
41 ce.CompanyType = 1;
42 ce.Save();
44 Entity[] ents = Entity.FindAll();
45 Assert.AreEqual( 2, ents.Length );
47 CompanyEntity[] ces = CompanyEntity.FindAll();
48 Assert.AreEqual( 1, ces.Length );
50 PersonEntity[] pes = PersonEntity.FindAll();
51 Assert.AreEqual( 0, pes.Length );
53 Assert.AreEqual( ce.CompId, ces[0].CompId );
54 Assert.AreEqual( ce.Name, ces[0].Name );
55 Assert.AreEqual( ce.Id, ces[0].Id );
58 [Test]
59 public void JoinedSubClass_WithAnyProperty()
61 ActiveRecordStarter.Initialize(GetConfigSource(),
62 typeof(Entity), typeof(CompanyEntity), typeof(PersonEntity), typeof(ManagerEntity));
63 Recreate();
65 Entity.DeleteAll();
66 CompanyEntity.DeleteAll();
67 PersonEntity.DeleteAll();
68 ManagerEntity.DeleteAll();
70 ManagerEntity manager = new ManagerEntity();
71 manager.Name = "pointy haired";
72 manager.Save();
74 PersonEntity person = new PersonEntity();
75 person.Name = "dilbert";
76 person.Manager = manager;
77 person.Save();
79 PersonEntity[] people = PersonEntity.FindAll();
80 Assert.AreEqual(1, people.Length);
81 Assert.IsNotNull(people[0].Manager);