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(); }
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>()); }
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); }
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(); }
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); }
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(); }
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(); }