Esempio n. 1
0
        public void tGetHeirarcyDeep()
        {
            var testSlide    = new Slide();
            var testNodeA1   = new DefaultNode();
            var testNodeA2   = new DefaultNode();
            var testNodeA1A1 = new DefaultNode();
            var testNodeA1A2 = new DefaultNode();
            var testNodeA2A1 = new DefaultNode();
            var testNodeA2A2 = new DefaultNode();

            testSlide.AddChild(testNodeA1);
            testSlide.AddChild(testNodeA2);
            testNodeA1.AddChild(testNodeA1A1);
            testNodeA1.AddChild(testNodeA1A2);
            testNodeA2.AddChild(testNodeA2A1);
            testNodeA2.AddChild(testNodeA2A2);

            testNodeA1A2.Description = "test description";

            var testView = ViewFactory.Instance.GetHierarchy(testSlide);

            Assert.AreEqual(typeof(SlideView), testView.GetType());
            Assert.AreEqual(typeof(DefaultNodeView), testView.GetChildViews().ElementAt(0).GetType());
            Assert.AreEqual(typeof(DefaultNodeView), testView.GetChildViews().ElementAt(1).GetType());
            Assert.AreEqual(typeof(DefaultNodeView), testView.GetChildViews().ElementAt(0).GetChildViews().ElementAt(0).GetType());
            Assert.AreEqual(typeof(DefaultNodeView), testView.GetChildViews().ElementAt(1).GetChildViews().ElementAt(1).GetType());

            var testNode = testView.GetChildViews().ElementAt(0).GetChildViews().ElementAt(1);

            var ptestNode          = new PrivateObject(testNode);
            var descriptionControl = (DraggableLabel)ptestNode.GetField("dlDescription");

            // test that the description property of testNodeA1A2 was applied by GetHierarchy
            Assert.AreEqual("test description", descriptionControl.Text);
        }
Esempio n. 2
0
        public void tGetHierarchy()
        {
            var testSlide = new Slide();
            var testNode  = new DefaultNode();

            testSlide.AddChild(testNode);

            var testView = ViewFactory.Instance.GetHierarchy(testSlide);

            Assert.AreEqual(typeof(SlideView), testView.GetType());
            Assert.AreEqual(typeof(DefaultNodeView), testView.GetChildViews().ElementAt(0).GetType());
        }
Esempio n. 3
0
        public void tSerializer_DefaultNode()
        {
            var hc              = new HistoryController();
            var filename        = @"c:\temp\tSerializer_DefaultNode.xml";
            var slideCollection = new SlideCollection();
            var slide1          = new Slide {
                Name = "Slide1"
            };
            var child1 = new DefaultNode {
                Name        = "child1",
                Description = "child1_description",
                Comment     = "child1_comment",
                Background  = new System.Windows.Media.Color {
                    A = 1, B = 150, G = 160, R = 170
                },
                BorderType = BorderType.normal,
                Foreground = new System.Windows.Media.Color {
                    A = 1, R = 2, G = 3, B = 4
                },
                Location = new System.Windows.Point {
                    X = 1, Y = 2
                },
                ShapeType = ShapeType.rectangle,
                Size      = new System.Windows.Size {
                    Height = 1, Width = 2
                },
                Parent = null
            };

            slideCollection.AddChild(slide1);

            slide1.AddChild(child1);

            Serializer.Serialize(slideCollection, filename);
            var result = Serializer.DeSerialize(filename, hc);

            Assert.AreEqual(typeof(SlideCollection), result.GetType());
            var r = (SlideCollection)result;

            var Slide = r.Children[0];

            Assert.AreEqual(r.Guid, Slide.Parent.Guid);

            var tNode = (DefaultNode)Slide.Children[0];

            Assert.AreEqual(Slide.Guid, tNode.Parent.Guid);

            Assert.AreEqual("child1", tNode.Name);
            Assert.AreEqual("child1_description", tNode.Description);
            Assert.AreEqual("child1_comment", tNode.Comment);
            Assert.AreEqual(new System.Windows.Media.Color {
                A = 1, B = 150, G = 160, R = 170
            }, tNode.Background);
            Assert.AreEqual(BorderType.normal, tNode.BorderType);
            Assert.AreEqual(new System.Windows.Media.Color {
                A = 1, R = 2, G = 3, B = 4
            }, tNode.Foreground);
            Assert.AreEqual(new System.Windows.Point {
                X = 1, Y = 2
            }, tNode.Location);
            Assert.AreEqual(ShapeType.rectangle, tNode.ShapeType);
            Assert.AreEqual(new System.Windows.Size {
                Height = 1, Width = 2
            }, tNode.Size);
        }
Esempio n. 4
0
        public void tSerializer_Slides()
        {
            var filename        = @"c:\temp\tSerializer_Slides.xml";
            var slideCollection = new SlideCollection();
            var slide1          = new Slide {
                Name = "Slide1"
            };
            var slide2 = new Slide {
                Name = "Slide2"
            };
            var child1 = new VisualNode {
                Name        = "child1",
                Description = "child1_description",
                Comment     = "child1_comment",
                Parent      = null
            };
            var child2 = new VisualNode {
                Name        = "child2",
                Description = "child2_description",
                Comment     = "child2_comment",
                Parent      = null
            };
            var child3 = new VisualNode {
                Name        = "child3",
                Description = "child3_description",
                Comment     = "child3_comment",
                Parent      = null
            };
            var child4 = new VisualNode {
                Name        = "child4",
                Description = "child4_description",
                Comment     = "child4_comment",
                Parent      = null
            };

            slideCollection.AddChild(slide1);
            slideCollection.AddChild(slide2);

            slide1.AddChild(child1);
            slide1.AddChild(child2);

            slide2.AddChild(child3);
            slide2.AddChild(child4);

            Serializer.Serialize(slideCollection, filename);
            var result = Serializer.DeSerialize(filename);

            Assert.AreEqual(typeof(SlideCollection), result.GetType());
            var r = (SlideCollection)result;

            // The Parent properties of both slides in the slide collection should reference the
            // slide collection.
            var firstSlide  = r.Children[0];
            var secondSlide = r.Children[1];

            Assert.AreEqual(r.Guid, firstSlide.Parent.Guid);
            Assert.AreEqual(r.Guid, secondSlide.Parent.Guid);

            // The Parent properties of both children of the first slide should reference the
            // first slide.
            var firstChild  = firstSlide.Children[0];
            var secondChild = firstSlide.Children[1];

            Assert.AreEqual(firstSlide.Guid, firstChild.Parent.Guid);
            Assert.AreEqual(firstSlide.Guid, secondChild.Parent.Guid);

            // The Parent properties of both children of the secode slide should reference the
            // second slide.
            firstChild  = secondSlide.Children[0];
            secondChild = secondSlide.Children[1];
            Assert.AreEqual(secondSlide.Guid, firstChild.Parent.Guid);
            Assert.AreEqual(secondSlide.Guid, secondChild.Parent.Guid);
        }
        public void tFileStoreContoller()
        {
            var hc              = new HistoryController();
            var filename        = @"c:\temp\tFileStoreContoller_HistoryController.xml";
            var slideCollection = new SlideCollection();
            var slide1          = new Slide {
                Name = "Slide1"
            };
            var slide2 = new Slide {
                Name = "Slide2"
            };
            var child1 = new DefaultNode {
                Name        = "child1",
                Description = "child1_description",
                Comment     = "child1_comment",
                Parent      = null
            };
            var child2 = new VisualNode {
                Name        = "child2",
                Description = "child2_description",
                Comment     = "child2_comment",
                Parent      = null
            };
            var child3 = new VisualNode {
                Name        = "child3",
                Description = "child3_description",
                Comment     = "child3_comment",
                Parent      = null
            };
            var child4 = new VisualNode {
                Name        = "child4",
                Description = "child4_description",
                Comment     = "child4_comment",
                Parent      = null
            };

            slideCollection.AddChild(slide1);
            slideCollection.AddChild(slide2);

            slide1.AddChild(child1);
            slide1.AddChild(child2);

            slide2.AddChild(child3);
            slide2.AddChild(child4);

            var fileStoreController = new FileStoreController();

            fileStoreController.PersistSlideCollection(filename, slideCollection);
            var result = fileStoreController.RestoreSlideCollection(filename, hc);

            Assert.AreEqual(typeof(SlideCollection), result.GetType());
            var r = (SlideCollection)result;

            // The Parent properties of both slides in the slide collection should reference the
            // slide collection.
            var firstSlide  = r.Children[0];
            var secondSlide = r.Children[1];

            Assert.AreEqual(r.Guid, firstSlide.Parent.Guid);
            Assert.AreEqual(r.Guid, secondSlide.Parent.Guid);

            // The Parent properties of both children of the first slide should reference the
            // first slide.
            var firstChild  = firstSlide.Children[0];
            var secondChild = firstSlide.Children[1];

            Assert.AreEqual(firstSlide.Guid, firstChild.Parent.Guid);
            Assert.AreEqual(firstSlide.Guid, secondChild.Parent.Guid);

            // The Parent properties of both children of the second slide should reference the
            // second slide.
            firstChild  = secondSlide.Children[0];
            secondChild = secondSlide.Children[1];
            Assert.AreEqual(secondSlide.Guid, firstChild.Parent.Guid);
            Assert.AreEqual(secondSlide.Guid, secondChild.Parent.Guid);

            firstChild.Name = "testA";
            Assert.AreEqual("testA", firstChild.Name);

            firstChild.Name = "testB";
            Assert.AreEqual("testB", firstChild.Name);

            hc.Undo();
            Assert.AreEqual("testA", firstChild.Name);

            hc.Redo();
            Assert.AreEqual("testB", firstChild.Name);
        }