9using System.Collections.Generic;
16using TestClass = NUnit.Framework.TestFixtureAttribute;
17using TestInitialize = NUnit.Framework.SetUpAttribute;
18using TestCleanup = NUnit.Framework.TearDownAttribute;
19using TestMethod = NUnit.Framework.TestAttribute;
20using TestSetup = NUnit.Framework.SetUpAttribute;
22using Microsoft.VisualStudio.TestTools.UnitTesting;
36 _testDIContext = TestDIContextFactory.CreateDefaultContext();
60 var root = dataPortal.
Fetch(
false);
61 root.PropertyChanged += (o, e) =>
65 root.ChildChanged += (o, e) =>
70 Assert.IsTrue(pc,
"PropertyChanged should have fired");
71 Assert.IsFalse(cc,
"ChildChanged should not have fired");
82 var root = dataPortal.
Fetch(
false);
83 root.PropertyChanged += (o, e) =>
87 root.ChildChanged += (o, e) =>
91 root.Child.Name =
"abc";
92 Assert.IsFalse(pc,
"PropertyChanged should not have fired");
93 Assert.IsTrue(cc,
"ChildChanged should have fired");
107 var root = dataPortal.
Fetch();
108 root.PropertyChanged += (o, e) =>
112 root.ChildChanged += (o, e) =>
116 root.Child.PropertyChanged += (o, e) =>
120 root.Child.ChildChanged += (o, e) =>
125 root.Child.Child.Name =
"abc";
126 Assert.IsFalse(cpc,
"C PropertyChanged should not have fired");
127 Assert.IsTrue(ccc,
"C ChildChanged should have fired");
128 Assert.IsFalse(pc,
"PropertyChanged should not have fired");
129 Assert.IsTrue(cc,
"ChildChanged should have fired");
130 Assert.IsTrue(ReferenceEquals(root.Child.Child, cca.ChildObject),
"Ref should be equal");
143 var root = listDataPortal.
Fetch(
false);
144 root.Add(dataPortal.Fetch(
true));
145 System.ComponentModel.PropertyDescriptor lcp =
null;
146 root.ListChanged += (o, e) =>
149 lcp = e.PropertyDescriptor;
151 root.ChildChanged += (o, e) =>
156 root[0].Name =
"abc";
157 Assert.AreEqual(1, lc,
"ListChanged should have fired");
158 Assert.IsNotNull(lcp,
"PropertyDescriptor should be provided");
159 Assert.AreEqual(
"Name", lcp.Name,
"PropertyDescriptor.Name should be Name");
160 Assert.AreEqual(1, cc,
"ChildChanged should have fired");
161 Assert.IsTrue(ReferenceEquals(root[0], cca.ChildObject),
"Ref should be equal");
174 var root = listDataPortal.
Fetch(
false);
175 root.Add(dataPortal.Fetch(
true));
178 System.ComponentModel.PropertyDescriptor lcp =
null;
179 root.ListChanged += (o, e) =>
182 lcp = e.PropertyDescriptor;
184 root.ChildChanged += (o, e) =>
189 root[0].Name =
"abc";
190 Assert.AreEqual(1, lc,
"ListChanged should have fired once");
191 Assert.IsNotNull(lcp,
"PropertyDescriptor should be provided");
192 Assert.AreEqual(
"Name", lcp.Name,
"PropertyDescriptor.Name should be Name");
193 Assert.AreEqual(1, cc,
"ChildChanged should have fired");
194 Assert.IsTrue(ReferenceEquals(root[0], cca.ChildObject),
"Ref should be equal");
208 var root = listDataPortal.
Fetch();
209 root.List.Add(dataPortal.Fetch(
true));
210 root.PropertyChanged += (o, e) =>
212 Assert.IsTrue(
false,
"root.PropertyChanged should not fire");
214 root.ChildChanged += (o, e) =>
218 System.ComponentModel.PropertyDescriptor lcp =
null;
219 root.List.ListChanged += (o, e) =>
222 lcp = e.PropertyDescriptor;
224 root.List.ChildChanged += (o, e) =>
229 root.List[0].Name =
"abc";
230 Assert.AreEqual(1, lc,
"ListChanged should have fired");
231 Assert.IsNotNull(lcp,
"PropertyDescriptor should be provided");
232 Assert.AreEqual(
"Name", lcp.Name,
"PropertyDescriptor.Name should be Name");
233 Assert.AreEqual(1, rcc,
"root.ChildChanged should have fired");
234 Assert.AreEqual(1, cc,
"list.ChildChanged should have fired");
235 Assert.IsTrue(ReferenceEquals(root.List[0], cca.ChildObject),
"Ref should be equal");
249 var root = listDataPortal.
Fetch();
250 root.List.Add(dataPortal.Fetch(
true));
253 root.PropertyChanged += (o, e) =>
255 Assert.IsTrue(
false,
"root.PropertyChanged should not fire");
257 root.ChildChanged += (o, e) =>
261 System.ComponentModel.PropertyDescriptor lcp =
null;
262 root.List.ListChanged += (o, e) =>
265 lcp = e.PropertyDescriptor;
267 root.List.ChildChanged += (o, e) =>
272 root.List[0].Name =
"abc";
273 Assert.AreEqual(1, lc,
"ListChanged should have fired once");
274 Assert.IsNotNull(lcp,
"PropertyDescriptor should be provided");
275 Assert.AreEqual(
"Name", lcp.Name,
"PropertyDescriptor.Name should be Name");
276 Assert.AreEqual(1, rcc,
"root.ChildChanged should have fired");
277 Assert.AreEqual(1, cc,
"list.ChildChanged should have fired");
278 Assert.IsTrue(ReferenceEquals(root.List[0], cca.ChildObject),
"Ref should be equal");
293 var root = listContainerDataPortal.
Fetch();
294 var child = listDataPortal.Fetch(
true);
296 child.List.Add(dataPortal.Fetch(
true));
297 root.ChildChanged += (o, e) =>
301 System.ComponentModel.PropertyDescriptor lcp =
null;
302 root.ListChanged += (o, e) =>
304 Assert.Fail(
"root.ListChanged should not fire");
306 child.ChildChanged += (o, e) =>
310 child.PropertyChanged += (o, e) =>
312 Assert.IsTrue(
false,
"child.PropertyChanged should not fire");
315 child.List.ListChanged += (o, e) =>
318 lcp = e.PropertyDescriptor;
320 child.List.ChildChanged += (o, e) =>
325 child.List[0].Name =
"abc";
326 Assert.IsTrue(lc,
"ListChanged should have fired");
327 Assert.IsNotNull(lcp,
"PropertyDescriptor should be provided");
328 Assert.AreEqual(
"Name", lcp.Name,
"PropertyDescriptor.Name should be Name");
329 Assert.IsTrue(rcc,
"root.ChildChanged should have fired");
330 Assert.IsTrue(ccc,
"child.ChildChanged should have fired");
331 Assert.IsTrue(cc,
"list.ChildChanged should have fired");
332 Assert.IsTrue(ReferenceEquals(child.List[0], cca.ChildObject),
"Ref should be equal");
Provides consistent context information between the client and server DataPortal objects.
static PropertyChangedModes PropertyChangedMode
Gets or sets a value specifying how CSLA .NET should raise PropertyChanged events.
PropertyChangedModes
Enum representing the way in which CSLA .NET should raise PropertyChanged events.
Contains event data about the changed child object.
void SingleList_Serialized()
static void ClassInitialize(TestContext testContext)
void ContainedList_Serialized()
Type to carry context information for DI in unit tests
Interface defining the members of the data portal type.
object Fetch(params object[] criteria)
Called by a factory method in a business class to retrieve an object, which is loaded with values fro...