Added RedirectUsingNamedRoute
[castle.git] / ActiveRecord / Castle.ActiveRecord.Tests / NestedClassWithRelationsTestCase.cs
blob4197b9df6618f0974cdba927273f1456469aa99e
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;
19 using NUnit.Framework;
21 using Castle.ActiveRecord.Tests.Model.Nested;
24 [TestFixture]
25 public class NestedClassWithRelationsTestCase : AbstractActiveRecordTest
27 [Test]
28 public void Operations()
30 ActiveRecordStarter.Initialize( GetConfigSource(),
31 typeof(Operation), typeof(PaymentPlan),
32 typeof(Convention), typeof(Payment));
33 Recreate();
35 Operation.DeleteAll();
37 Operation operation = new Operation();
38 operation.Save();
40 operation = Operation.Find(operation.Id);
41 Assert.AreEqual(1, operation.Id);
42 Assert.IsNotNull(operation.PaymentPlan);
44 operation.PaymentPlan.ExpirationDate = DateTime.Today.AddDays(-10);
45 operation.PaymentPlan.NumberOfPayments = 12;
46 operation.Save();
48 Convention convention = new Convention();
49 convention.Description = "It works!";
50 convention.Save();
52 operation.PaymentPlan.Convention = convention;
53 operation.Save();
55 operation = Operation.Find(operation.Id);
56 Assert.IsNotNull(operation.PaymentPlan.Convention);
57 Assert.AreEqual(convention.Description, operation.PaymentPlan.Convention.Description);
59 Payment payment1 = new Payment();
60 payment1.Expiration =DateTime.Today.AddDays(10);
61 payment1.Amount = 10;
62 payment1.Save();
64 operation.PaymentPlan.Payments.Add(payment1);
65 operation.Save();
67 int id = operation.Id;
68 operation = null;
69 operation = Operation.Find(id);
71 Assert.AreEqual(1, operation.PaymentPlan.Payments.Count);