public void BoggleGraphTest_Contains_Node_WhenNodePresent_ReturnsTrue() { BoggleNode node = new BoggleNode(0, 1); BoggleGraph graph = new BoggleGraph(); graph.Add(node); Assert.IsTrue(graph.Contains(node)); }
public void BoggleEdge_Equals_WhenEitherVertexIsNull_ReturnsFalse() { BoggleNode vOne = new BoggleNode(0, 0); BoggleNode vTwo = new BoggleNode(1, 0); BoggleEdge one = new BoggleEdge(vOne, vTwo); BoggleEdge two = new BoggleEdge(vOne, null); Assert.IsFalse(one.Equals(two)); Assert.IsFalse(two.Equals(one)); two.VertexOne = null; two.VertexTwo = vTwo; Assert.IsFalse(one.Equals(two)); Assert.IsFalse(two.Equals(one)); one.VertexOne = null; one.VertexTwo = vTwo; two.VertexOne = vOne; two.VertexTwo = vTwo; Assert.IsFalse(one.Equals(two)); Assert.IsFalse(two.Equals(one)); one.VertexOne = vOne; one.VertexTwo = null; two.VertexOne = vOne; two.VertexTwo = vTwo; Assert.IsFalse(one.Equals(two)); Assert.IsFalse(two.Equals(one)); }
public BoggleGraph Add(BoggleNode node) { if (_nodes == null) _nodes = new List<BoggleNode>(); if(node != null && !this.Contains(node)) _nodes.Add(node); return this; }
public void BoggleGraphTest_Add_Node_DoesntAddDupes() { BoggleNode node = new BoggleNode(0, 0); BoggleGraph graph = new BoggleGraph(); graph.Add(node); Assert.IsTrue(graph.NodeCount == 1); graph.Add(node); Assert.IsTrue(graph.NodeCount == 1); graph.Add(node); Assert.IsTrue(graph.NodeCount == 1); }
public void BoggleNode_IsImmediatelyAbove_ReturnsTrue_WhenCallerIsImmediatelyAboveArg() { BoggleNode n1 = new BoggleNode(); BoggleNode n2 = new BoggleNode(); n1.X = 10; n1.Y = 4; n2.X = n1.X; n2.Y = n1.Y + 1; Assert.IsTrue(n1.IsImmediatelyAbove(n2)); }
public void BoggleEdge_Equals_ReturnsTrueWhenBothAreEqual() { BoggleNode vOne = new BoggleNode(0, 0); BoggleNode vTwo = new BoggleNode(1, 0); BoggleEdge one = new BoggleEdge(vOne, vTwo); BoggleEdge two = new BoggleEdge(vOne, vTwo); Assert.IsTrue(one.Equals(two)); Assert.IsTrue(two.Equals(one)); // now swap the vertex orders - the edges should still be equal one.VertexOne = vOne; one.VertexTwo = vTwo; two.VertexOne = vTwo; two.VertexTwo = vOne; Assert.IsTrue(one.Equals(two)); Assert.IsTrue(two.Equals(one)); }
public void BoggleNode_IsImmediatelyAbove_ReturnsFalse_WhenCallerIsNotImmediatelyAboveArg() { BoggleNode n1 = new BoggleNode(); BoggleNode n2 = new BoggleNode(); n1.X = 10; n1.Y = 10; // left,down n2.X = n1.X - 1; n2.Y = n1.Y + 1; Assert.IsFalse(n1.IsImmediatelyAbove(n2)); // left n2.X = n1.X - 1; n2.Y = n1.Y; Assert.IsFalse(n1.IsImmediatelyAbove(n2)); // left,up n2.X = n1.X - 1; n2.Y = n1.Y - 1; Assert.IsFalse(n1.IsImmediatelyAbove(n2)); // right,up n2.X = n1.X + 1; n2.Y = n1.Y - 1; Assert.IsFalse(n1.IsImmediatelyAbove(n2)); // right n2.X = n1.X + 1; n2.Y = n1.Y; Assert.IsFalse(n1.IsImmediatelyAbove(n2)); // right,down n2.X = n1.X + 1; n2.Y = n1.Y + 1; Assert.IsFalse(n1.IsImmediatelyAbove(n2)); }
public bool Contains(BoggleNode node) { if (node == null || _nodes == null) return false; return _nodes.Contains(node); }
public void BoggleGraphTest_Equals_ReturnsTrueWhenEquals_RegardlesOfNodeOrdering() { BoggleGraph g1 = new BoggleGraph(); BoggleGraph g2 = new BoggleGraph(); BoggleNode n1 = new BoggleNode(0, 0); BoggleNode n2 = new BoggleNode(1, 0); BoggleNode n3 = new BoggleNode(2, 0); // insert nodes out of order to verify that ordering doesn't effect graph equality g1.Add(n1); g1.Add(n2); g1.Add(n3); g2.Add(n3); g2.Add(n1); g2.Add(n2); Assert.AreEqual(g1, g2); }
public bool IsNeighborsWith(BoggleNode node) { if (node == null) return false; return false; }
/// <summary> /// Helper that returns true if this node is immediately below /// the given node, false otherwise. /// </summary> public bool IsImmediatelyBelow(BoggleNode node) { if (node == null) return false; return this.Y == (node.Y + 1) && this.X == node.X; }
public BoggleEdge(BoggleNode one, BoggleNode two) { this.VertexOne = one; this.VertexTwo = two; }
public BoggleEdge() { this.VertexOne = null; this.VertexTwo = null; }