Example #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();
        }
Example #2
0
        public void Head_HasNoParent()
        {
            var tableEntity = new TableEntity()
            {
                Eid = 0
            };
            var dictionaryGraphNode = new DictionaryGraphNode <TableEntity>(tableEntity.Eid, tableEntity);

            dictionaryGraphNode.Parent.Should().BeNull();
        }
Example #3
0
        public void CreateNew_ContainsOwnEid()
        {
            var tableEntity = new TableEntity()
            {
                Eid = 0
            };

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

            dictionaryGraphNode.ContainsKey(tableEntity.Eid).Should().BeTrue();
        }
Example #4
0
        public void CreateNew_ReturnsCorrectEid()
        {
            var tableEntity = new TableEntity()
            {
                Eid = 0
            };

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

            dictionaryGraphNode.Eid.Should().Be(tableEntity.Eid);
        }
Example #5
0
        public void CreateNew_GetItselfReturnsCorrectly()
        {
            var tableEntity = new TableEntity()
            {
                Eid = 0
            };
            var dictionaryGraphNode = new DictionaryGraphNode <TableEntity>(tableEntity.Eid, tableEntity);

            var response = dictionaryGraphNode.Get(tableEntity.Eid);

            response.Should().Be(tableEntity);
        }
Example #6
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>());
        }
Example #7
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);
        }
Example #8
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();
        }
Example #9
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);
        }
Example #10
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();
        }
Example #11
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();
        }