Esempio n. 1
0
        public void ListOfLists()
        {
            bool rcc = false;
            bool ccc = false;
            bool cc  = false;

            Csla.Core.ChildChangedEventArgs cca = null;

            var root  = new ListContainerList();
            var child = new ContainsList(true);

            root.Add(child);
            child.List.Add(new SingleRoot(true));
            root.ChildChanged += (o, e) =>
            {
                rcc = true;
            };
            System.ComponentModel.PropertyDescriptor lcp = null;
            root.ListChanged += (o, e) =>
            {
                Assert.Fail("root.ListChanged should not fire");
            };
            child.ChildChanged += (o, e) =>
            {
                ccc = true;
            };
            child.PropertyChanged += (o, e) =>
            {
                Assert.IsTrue(false, "child.PropertyChanged should not fire");
            };
            bool lc = false;

            child.List.ListChanged += (o, e) =>
            {
                lc  = true;
                lcp = e.PropertyDescriptor;
            };
            child.List.ChildChanged += (o, e) =>
            {
                cc  = true;
                cca = e;
            };
            child.List[0].Name = "abc";
            Assert.IsTrue(lc, "ListChanged should have fired");
            Assert.IsNotNull(lcp, "PropertyDescriptor should be provided");
            Assert.AreEqual("Name", lcp.Name, "PropertyDescriptor.Name should be Name");
            Assert.IsTrue(rcc, "root.ChildChanged should have fired");
            Assert.IsTrue(ccc, "child.ChildChanged should have fired");
            Assert.IsTrue(cc, "list.ChildChanged should have fired");
            Assert.IsTrue(ReferenceEquals(child.List[0], cca.ChildObject), "Ref should be equal");
        }
Esempio n. 2
0
        public void ContainedList_Serialized()
        {
            int lc  = 0;
            int rcc = 0;
            int cc  = 0;

            Csla.Core.ChildChangedEventArgs cca = null;

            var root = new ContainsList();

            root.List.Add(new SingleRoot(true));
            root = root.Clone();

            root.PropertyChanged += (o, e) =>
            {
                Assert.IsTrue(false, "root.PropertyChanged should not fire");
            };
            root.ChildChanged += (o, e) =>
            {
                rcc++;
            };
#if !SILVERLIGHT
            System.ComponentModel.PropertyDescriptor lcp = null;
            root.List.ListChanged += (o, e) =>
            {
                lc++;
                lcp = e.PropertyDescriptor;
            };
#else
            root.List.CollectionChanged += (o, e) =>
            {
                lc++;
            };
#endif
            root.List.ChildChanged += (o, e) =>
            {
                cc++;
                cca = e;
            };
            root.List[0].Name = "abc";
#if !SILVERLIGHT
            Assert.AreEqual(1, lc, "ListChanged should have fired");
            Assert.IsNotNull(lcp, "PropertyDescriptor should be provided");
            Assert.AreEqual("Name", lcp.Name, "PropertyDescriptor.Name should be Name");
#endif
            Assert.AreEqual(1, rcc, "root.ChildChanged should have fired");
            Assert.AreEqual(1, cc, "list.ChildChanged should have fired");
            Assert.IsTrue(ReferenceEquals(root.List[0], cca.ChildObject), "Ref should be equal");
        }