1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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
19 using NUnit
.Framework
;
21 using Castle
.ActiveRecord
.Tests
.Model
.Nested
;
25 public class NestedClassWithRelationsTestCase
: AbstractActiveRecordTest
28 public void Operations()
30 ActiveRecordStarter
.Initialize( GetConfigSource(),
31 typeof(Operation
), typeof(PaymentPlan
),
32 typeof(Convention
), typeof(Payment
));
35 Operation
.DeleteAll();
37 Operation operation
= new Operation();
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;
48 Convention convention
= new Convention();
49 convention
.Description
= "It works!";
52 operation
.PaymentPlan
.Convention
= convention
;
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);
64 operation
.PaymentPlan
.Payments
.Add(payment1
);
67 int id
= operation
.Id
;
69 operation
= Operation
.Find(id
);
71 Assert
.AreEqual(1, operation
.PaymentPlan
.Payments
.Count
);