Exemplo n.º 1
0
        public void TestLevelDown()
        {
            var parent = new Org(Guid.NewGuid())
            {
                Name = "parentName"
            };
            var child1 = new Org(Guid.NewGuid())
            {
                Name = "child1"
            };
            var child2 = new Org(Guid.NewGuid())
            {
                Name = "child2"
            };
            var child3 = new Org(Guid.NewGuid())
            {
                Name = "child2"
            };

            parent.Add(child1);
            parent.Add(child2);
            parent.Add(child3);

            Assert.IsTrue(child2.LevelDown(child3));

            Assert.AreEqual(child3, child2.Parent);
        }
Exemplo n.º 2
0
        public void TestLevelDown()
        {
            var parent = new Org(Guid.NewGuid()) {Name = "parentName"};
            var child1 = new Org(Guid.NewGuid()) {Name = "child1"};
            var child2 = new Org(Guid.NewGuid()) {Name = "child2"};
            var child3 = new Org(Guid.NewGuid()) {Name = "child2"};

            parent.Add(child1);
            parent.Add(child2);
            parent.Add(child3);

            Assert.IsTrue(child2.LevelDown(child3));

            Assert.AreEqual(child3, child2.Parent);
        }
Exemplo n.º 3
0
        public void TestChildAddParentFaile()
        {
            var parent = new Org(Guid.NewGuid())
            {
                Name = "parentName"
            };
            var child1 = new Org(Guid.NewGuid())
            {
                Name = "child1"
            };
            var child1Child = new Org(Guid.NewGuid())
            {
                Name = "child1child"
            };
            var child1Child_Chidl = new Org(Guid.NewGuid())
            {
                Name = "child1child"
            };

            parent.Add(child1);
            child1.Add(child1Child);
            child1Child.Add(child1Child_Chidl);

            child1Child_Chidl.Add(parent);
        }
Exemplo n.º 4
0
        public void TestAddChild()
        {
            var parent = new Org(Guid.NewGuid())
            {
                Name = "parentName"
            };
            var child1 = new Org(Guid.NewGuid())
            {
                Name = "child1"
            };
            var child1Child = new Org(Guid.NewGuid())
            {
                Name = "child1child"
            };

            child1.Add(child1Child);
            Assert.AreEqual(child1.Id.ToString(), child1Child.OrderId);
            Assert.AreEqual(child1, child1Child.Parent);
            Assert.IsTrue(child1.Contains(child1Child));

            parent.Add(child1);
            Assert.AreEqual(parent.Id.ToString(), child1.OrderId);
            Assert.AreEqual(parent.Id + "." + child1.Id, child1Child.OrderId);
            Assert.AreEqual(parent, child1.Parent);
        }
Exemplo n.º 5
0
        public void TestMappingSetting()
        {
            var parent = new Org("Name")
            {
                Comment = "comment"
            };

            var child = new Org("childName")
            {
                Comment = "childComment"
            };

            var dao = new OrgDao();

            dao.SaveOrUpdate(parent);
            dao.Save(child);
            parent.Add(child);


            Org dbParent = dao.Get(parent.Id);

            Assert.AreEqual(parent.Name, dbParent.Name);
            Assert.AreEqual(parent.Comment, dbParent.Comment);
            Assert.AreEqual(1, dbParent.OrgCount);

            Org dbChild = dao.Get(child.Id);

            Assert.AreEqual(parent, dbChild.Parent);
        }
Exemplo n.º 6
0
        public void TestChildAddParentFaile()
        {
            var parent = new Org(Guid.NewGuid()) {Name = "parentName"};
            var child1 = new Org(Guid.NewGuid()) {Name = "child1"};
            var child1Child = new Org(Guid.NewGuid()) {Name = "child1child"};
            var child1Child_Chidl = new Org(Guid.NewGuid()) {Name = "child1child"};

            parent.Add(child1);
            child1.Add(child1Child);
            child1Child.Add(child1Child_Chidl);

            child1Child_Chidl.Add(parent);
        }
Exemplo n.º 7
0
        public void TestLevelDownItsChildFaile()
        {
            var parent = new Org(Guid.NewGuid())
            {
                Name = "parentName"
            };
            var child1 = new Org(Guid.NewGuid())
            {
                Name = "child1"
            };

            parent.Add(child1);

            Assert.IsTrue(parent.LevelDown(child1));
        }
Exemplo n.º 8
0
        public void TestAddChild()
        {
            var parent = new Org(Guid.NewGuid()) {Name = "parentName"};
            var child1 = new Org(Guid.NewGuid()) {Name = "child1"};
            var child1Child = new Org(Guid.NewGuid()) {Name = "child1child"};

            child1.Add(child1Child);
            Assert.AreEqual(child1.Id.ToString(), child1Child.OrderId);
            Assert.AreEqual(child1, child1Child.Parent);
            Assert.IsTrue(child1.Contains(child1Child));

            parent.Add(child1);
            Assert.AreEqual(parent.Id.ToString(), child1.OrderId);
            Assert.AreEqual(parent.Id + "." + child1.Id, child1Child.OrderId);
            Assert.AreEqual(parent, child1.Parent);
        }
Exemplo n.º 9
0
        public void TestMappingSetting()
        {
            var parent = new Org("Name") {Comment = "comment"};

            var child = new Org("childName") {Comment = "childComment"};

            var dao = new OrgDao();
            dao.SaveOrUpdate(parent);
            dao.Save(child);
            parent.Add(child);

            Org dbParent = dao.Get(parent.Id);
            Assert.AreEqual(parent.Name, dbParent.Name);
            Assert.AreEqual(parent.Comment, dbParent.Comment);
            Assert.AreEqual(1, dbParent.OrgCount);

            Org dbChild = dao.Get(child.Id);
            Assert.AreEqual(parent, dbChild.Parent);
        }
Exemplo n.º 10
0
        public void TestLevelUp()
        {
            var parent = new Org(Guid.NewGuid())
            {
                Name = "parentName"
            };
            var child1 = new Org(Guid.NewGuid())
            {
                Name = "child1"
            };

            parent.Add(child1);


            Assert.IsFalse(parent.LevelUp());

            Assert.IsTrue(child1.LevelUp());
            Assert.IsNull(child1.Parent);
            Assert.IsNull(child1.OrderId);
            Assert.IsFalse(parent.Contains(child1));
        }
Exemplo n.º 11
0
        public void TestLevelDownItsChildFaile()
        {
            var parent = new Org(Guid.NewGuid()) {Name = "parentName"};
            var child1 = new Org(Guid.NewGuid()) {Name = "child1"};

            parent.Add(child1);

            Assert.IsTrue(parent.LevelDown(child1));
        }
Exemplo n.º 12
0
        public void TestLevelUp()
        {
            var parent = new Org(Guid.NewGuid()) {Name = "parentName"};
            var child1 = new Org(Guid.NewGuid()) {Name = "child1"};

            parent.Add(child1);

            Assert.IsFalse(parent.LevelUp());

            Assert.IsTrue(child1.LevelUp());
            Assert.IsNull(child1.Parent);
            Assert.IsNull(child1.OrderId);
            Assert.IsFalse(parent.Contains(child1));
        }