public void MyNode_Test_AddConnections_() { MyNode <int> n1 = new MyNode <int>(31); MyNode <int> n2 = new MyNode <int>(32); MyNode <int> n3 = new MyNode <int>(33); MyNode <int> n4 = new MyNode <int>(34); MyNode <int> n5 = new MyNode <int>(35); MyNode <int> n6 = new MyNode <int>(36); List <MyNode <int> > nodes = new List <MyNode <int> >() { n2, n3, n4, n5, n6 }; Assert.IsTrue(n1.AddConnections(nodes)); Assert.IsTrue(n1.NEIGHBORS.Contains(n2)); Assert.IsFalse(n2.NEIGHBORS.Contains(n1)); Assert.IsTrue(n1.NEIGHBORS.Contains(n3)); Assert.IsFalse(n3.NEIGHBORS.Contains(n1)); Assert.IsTrue(n1.NEIGHBORS.Contains(n4)); Assert.IsFalse(n4.NEIGHBORS.Contains(n1)); Assert.IsTrue(n1.NEIGHBORS.Contains(n5)); Assert.IsFalse(n5.NEIGHBORS.Contains(n1)); Assert.IsTrue(n1.NEIGHBORS.Contains(n6)); Assert.IsFalse(n6.NEIGHBORS.Contains(n1)); }
public void MyNode_Test_RemoveConnections_() { MyNode <int> n1 = new MyNode <int>(31); MyNode <int> n2 = new MyNode <int>(32); MyNode <int> n3 = new MyNode <int>(33); MyNode <int> n4 = new MyNode <int>(34); MyNode <int> n5 = new MyNode <int>(35); MyNode <int> n6 = new MyNode <int>(36); List <MyNode <int> > nodes = new List <MyNode <int> >() { n2, n3, n4, n5, n6 }; n1.AddConnections(nodes); List <MyNode <int> > subnodesEven = new List <MyNode <int> >() { n2, n4, n6 }; Assert.IsTrue(n1.RemoveConnections(subnodesEven)); Assert.IsFalse(n1.NEIGHBORS.Contains(n2)); Assert.IsFalse(n1.NEIGHBORS.Contains(n4)); Assert.IsFalse(n1.NEIGHBORS.Contains(n6)); List <MyNode <int> > subnodesOdd = new List <MyNode <int> >() { n3, n5 }; Assert.IsTrue(n1.RemoveConnections(subnodesOdd)); Assert.IsFalse(n1.NEIGHBORS.Contains(n3)); Assert.IsFalse(n1.NEIGHBORS.Contains(n5)); }
public void MyNode_Test_RemoveAllNeighbors_() { MyNode <int> n1 = new MyNode <int>(31); MyNode <int> n2 = new MyNode <int>(32); MyNode <int> n3 = new MyNode <int>(33); MyNode <int> n4 = new MyNode <int>(34); MyNode <int> n5 = new MyNode <int>(35); MyNode <int> n6 = new MyNode <int>(36); List <MyNode <int> > nodes = new List <MyNode <int> >() { n2, n3, n4, n5, n6 }; n1.AddConnections(nodes); n1.RemoveAllNeighbors(); Assert.IsTrue(n1.NEIGHBORS.Count == 0); }