public void GetNameShouldReturnAName()
 {
     Node target = new Node("Jacob");
     string actual = target.GetName();
     string expected = "Jacob";
     Assert.AreEqual(expected, actual);
 }
 public void SetNamesShouldChangeTheName()
 {
     Node target = new Node("Jacob");
     target.SetName("George");
     string actual = target.GetName();
     string expected = "George";
     Assert.AreEqual(expected, actual);
 }
 public void Enqueue(Node newNode)
 {
     newNode.SetNextNode(tailNode);
     tailNode = newNode;
     if (tailNode.GetNextNode() == null)
     {
         headNode = tailNode;
     }
 }
 public void DequeueShouldReturnHeadNode()
 {
     LinkedListQueue target = new LinkedListQueue();
     Node firstNode = new Node();
     target.Enqueue(firstNode);
     Node expected = firstNode;
     Node actual = target.Dequeue();
     Assert.AreEqual(expected, actual);
 }
 public void EnqueueShouldAddPreviousTailToNewTailsNextNode()
 {
     LinkedListQueue target = new LinkedListQueue();
     Node nodeOne = new Node();
     Node nodeTwo = new Node();
     target.Enqueue(nodeOne);
     target.Enqueue(nodeTwo);
     Node expected = nodeOne;
     Node actual = nodeTwo.GetNextNode();
     Assert.AreEqual(expected, actual);
 }
 public void ShouldBeAbleToGetAndSetNextNode()
 {
     Node nodeOne = new Node();
     Node target = new Node(nodeOne);
     Node expected = nodeOne;
     Node actual = target.GetNextNode();
     Assert.AreEqual(expected, actual);
     Node newNode = new Node("Emily");
     target.SetNextNode(newNode);
     expected = newNode;
     actual = target.GetNextNode();
     Assert.AreEqual(expected, actual);
 }
 private Node FindNodeByData(Node currentlySearchingNode, string data)
 {
     if (currentlySearchingNode.GetName() == data)
     {
         return currentlySearchingNode;
     }
     else if (currentlySearchingNode.GetNextNode() != null)
     {
         return FindNodeByData(currentlySearchingNode.GetNextNode(), data);
     }
     return null;
     // Recusion here is not ideal, due to the fact that, for a sufficiently large queue, this recursive loop will blow the stack
 }
 public void DequeueShouldCreateNewHeadNode()
 {
     LinkedListQueue target = new LinkedListQueue();
     Node firstNode = new Node();
     Node secondNode = new Node(firstNode);
     Node thirdNode = new Node(secondNode);
     target.Enqueue(firstNode);
     target.Enqueue(secondNode);
     target.Enqueue(thirdNode);
     target.Dequeue();
     Node expected = secondNode;
     Node actual = target.Head();
     Assert.AreEqual(expected, actual);
 }
 private Node FindNextHeadNode(Node currentlySearchingNode)
 {
     Node currentNode = tailNode;
     Node nextNode;
     while (currentNode != null)
     {
         if (currentNode.GetNextNode() == headNode)
         {
             return currentNode;
         }
         else
         {
             currentNode = currentNode.GetNextNode();
         }
     }
     return null;
 }
 public Node Dequeue()
 {
     Node temporaryNode = headNode;
     headNode = FindNextHeadNode(tailNode);
     return temporaryNode;
 }
예제 #11
0
 public void SetNextNode(Node desiredNextNode)
 {
     nextNode = desiredNextNode;
 }
 public void TailShouldReturnLastNodeInQueue()
 {
     LinkedListQueue target = new LinkedListQueue();
     Node newNode = new Node();
     target.Enqueue(newNode);
     Node expected = newNode;
     Node actual = target.Tail();
     Assert.AreEqual(expected, actual);
 }
 public void ShouldBeAbleToCreateNodes()
 {
     Node target = new Node();
 }
예제 #14
0
 public Node(string desiredName, Node desiredNextNode)
 {
     name = desiredName;
     nextNode = desiredNextNode;
 }
 public void EnqueueShouldTakeANode()
 {
     LinkedListQueue target = new LinkedListQueue();
     Node newNode = new Node();
     target.Enqueue(newNode);
 }
 public void ShouldBeAbleToCreateNodesWithNextNodes()
 {
     Node nodeOne = new Node("Jacob");
     Node nodeTwo = new Node("George", nodeOne);
     Node nodeThree = new Node(nodeTwo);
 }
 public void ShouldBeAbleToCreateNodesWithNames()
 {
     Node target = new Node("Jacob");
 }
 public void FindShouldReturnDesiredNode()
 {
     LinkedListQueue target = new LinkedListQueue();
     Node firstNode = new Node("First");
     Node secondNode = new Node("Second");
     Node thirdNode = new Node("Third");
     Node fourthNode = new Node("Fourth");
     target.Enqueue(firstNode);
     target.Enqueue(secondNode);
     target.Enqueue(thirdNode);
     target.Enqueue(fourthNode);
     Node actual = target.Find("Second");
     Node expected = secondNode;
     Assert.AreEqual(expected, actual);
 }
예제 #19
0
 public Node(Node desiredNextNode)
 {
     nextNode = desiredNextNode;
 }