0
|
1 using System;
|
|
2
|
|
3 using NUnit.Framework;
|
|
4
|
|
5 using BLToolkit.DataAccess;
|
|
6 using BLToolkit.EditableObjects;
|
|
7 using BLToolkit.Mapping;
|
|
8 using BLToolkit.Reflection;
|
|
9 using BLToolkit.TypeBuilder;
|
|
10
|
|
11 namespace A.EditableObjects
|
|
12 {
|
|
13 //[TestFixture]
|
|
14 public class EditableList_AcceptChanges
|
|
15 {
|
|
16 public static bool IsAcceptChangesCallForPersonPhone = false;
|
|
17
|
|
18 public abstract class _DomainObject : EditableObject
|
|
19 {
|
|
20 [PrimaryKey(0), NonUpdatable]
|
|
21 [NullValue()]
|
|
22 public abstract int ID { get; set; }
|
|
23
|
|
24 public override void AcceptChanges()
|
|
25 {
|
|
26 base.AcceptChanges();
|
|
27
|
|
28 if (typeof(_PersonPhone).IsAssignableFrom(GetType()))
|
|
29 IsAcceptChangesCallForPersonPhone = true;
|
|
30 }
|
|
31 }
|
|
32
|
|
33 public abstract class _PersonPhone : _DomainObject, IEditable
|
|
34 {
|
|
35 public abstract string Number_PersonPhone { get; set; }
|
|
36 }
|
|
37
|
|
38 public abstract class _Person : _DomainObject
|
|
39 {
|
|
40 public abstract EditableList<_PersonPhone> Phones { get; set; }
|
|
41 }
|
|
42
|
|
43 //[Test]
|
|
44 public void Test_EditableList_AcceptChanges()
|
|
45 {
|
|
46 _Person person = TypeAccessor<_Person>.CreateInstance();
|
|
47
|
|
48 person.Phones.AddRange(new _PersonPhone[]
|
|
49 {
|
|
50 TypeAccessor<_PersonPhone>.CreateInstanceEx(),
|
|
51 TypeAccessor<_PersonPhone>.CreateInstanceEx()
|
|
52 });
|
|
53
|
|
54 person.Phones[1].Number_PersonPhone = "222-22-22";
|
|
55
|
|
56 person.AcceptChanges();
|
|
57
|
|
58 Assert.IsFalse(person.IsDirty);
|
|
59 Assert.IsTrue(IsAcceptChangesCallForPersonPhone);
|
|
60 }
|
|
61 }
|
|
62 }
|