Esempio n. 1
0
        public void Remove_RemovesSecondDepthChild()
        {
            var tableEntity = new TableEntity()
            {
                Eid = 0
            };
            var tableEntity2 = new TableEntity()
            {
                Eid = 1
            };
            var tableEntity3 = new TableEntity()
            {
                Eid = 2
            };

            var dictionaryGraphNode3 = new DictionaryGraphNode <TableEntity>(tableEntity3.Eid, tableEntity3);
            var dictionaryGraphNode2 = new DictionaryGraphNode <TableEntity>(tableEntity2.Eid, tableEntity2);
            var dictionaryGraphNode  = new DictionaryGraphNode <TableEntity>(tableEntity.Eid, tableEntity);

            dictionaryGraphNode2.Add(dictionaryGraphNode3);
            dictionaryGraphNode.Add(dictionaryGraphNode2);

            dictionaryGraphNode.Remove(dictionaryGraphNode3);

            dictionaryGraphNode.Contains(dictionaryGraphNode3).Should().BeFalse();
        }
Esempio n. 2
0
        public void Add_CannotAddItself()
        {
            var tableEntity = new TableEntity()
            {
                Eid = 0
            };

            var dictionaryGraphNode = new DictionaryGraphNode <TableEntity>(tableEntity.Eid, tableEntity);

            Assert.That(() => dictionaryGraphNode.Add(dictionaryGraphNode),
                        Throws.TypeOf <InvalidOperationException>());
        }
Esempio n. 3
0
        public void Get_FindsChild()
        {
            var tableEntity = new TableEntity()
            {
                Eid = 0
            };
            var tableEntity2 = new TableEntity()
            {
                Eid = 1
            };
            var dictionaryGraphNode  = new DictionaryGraphNode <TableEntity>(tableEntity.Eid, tableEntity);
            var dictionaryGraphNode2 = new DictionaryGraphNode <TableEntity>(tableEntity2.Eid, tableEntity2);

            dictionaryGraphNode.Add(dictionaryGraphNode2);

            dictionaryGraphNode.Get(tableEntity2.Eid).Should().Be(tableEntity2);
        }
Esempio n. 4
0
        public void AddNew_ContainsNewEid()
        {
            var tableEntity = new TableEntity()
            {
                Eid = 0
            };
            var tableEntity2 = new TableEntity()
            {
                Eid = 1
            };
            var dictionaryGraphNode  = new DictionaryGraphNode <TableEntity>(tableEntity.Eid, tableEntity);
            var dictionaryGraphNode2 = new DictionaryGraphNode <TableEntity>(tableEntity2.Eid, tableEntity2);

            dictionaryGraphNode.Add(dictionaryGraphNode2);

            dictionaryGraphNode.ContainsKey(tableEntity2.Eid).Should().BeTrue();
        }
Esempio n. 5
0
        public void Add_ChildHasCorrectParent()
        {
            var tableEntity = new TableEntity()
            {
                Eid = 0
            };
            var tableEntity2 = new TableEntity()
            {
                Eid = 1
            };
            var dictionaryGraphNode  = new DictionaryGraphNode <TableEntity>(tableEntity.Eid, tableEntity);
            var dictionaryGraphNode2 = new DictionaryGraphNode <TableEntity>(tableEntity2.Eid, tableEntity2);

            dictionaryGraphNode.Add(dictionaryGraphNode2);

            dictionaryGraphNode2.Parent.Should().Be(dictionaryGraphNode);
        }
Esempio n. 6
0
        public void Remove_SetsChildParentToNull()
        {
            var tableEntity = new TableEntity()
            {
                Eid = 0
            };
            var tableEntity2 = new TableEntity()
            {
                Eid = 1
            };
            var dictionaryGraphNode  = new DictionaryGraphNode <TableEntity>(tableEntity.Eid, tableEntity);
            var dictionaryGraphNode2 = new DictionaryGraphNode <TableEntity>(tableEntity2.Eid, tableEntity2);

            dictionaryGraphNode.Add(dictionaryGraphNode2);

            dictionaryGraphNode.Remove(dictionaryGraphNode2);

            dictionaryGraphNode2.Parent.Should().BeNull();
        }
Esempio n. 7
0
        public void Remove_NoEntity_FalseReturned()
        {
            var tableEntity = new TableEntity()
            {
                Eid = 0
            };
            var tableEntity2 = new TableEntity()
            {
                Eid = 1
            };
            var dictionaryGraphNode  = new DictionaryGraphNode <TableEntity>(tableEntity.Eid, tableEntity);
            var dictionaryGraphNode2 = new DictionaryGraphNode <TableEntity>(tableEntity2.Eid, tableEntity2);

            dictionaryGraphNode.Add(dictionaryGraphNode2);

            var response = dictionaryGraphNode.Remove(3);

            response.Should().BeFalse();
        }