private static void Validate(Stack <int> src, Stack <int> dest, Stack <int> temp) { var size = src.Count; Question_8_6.MoveTower(src, dest, temp); Assert.AreEqual(0, src.Count); Assert.AreEqual(0, temp.Count); Assert.AreEqual(size, dest.Count); var destCopy = new Stack <int>(dest); var last = -1; while (destCopy.Count != 0) { var next = destCopy.Pop(); Assert.IsTrue(last < next); } }
public void MoveDisksTest(int numberOfDisks) { try { // Arrange var initialTower = GenerateTower(numberOfDisks); var finalTower = new Stack <int>(numberOfDisks); var expectedFinalTower = GenerateTower(numberOfDisks); // Act Question_8_6.MoveDisks(initialTower, finalTower); // Assert Assert.IsTrue(expectedFinalTower.SequenceEqual(finalTower)); } catch (InvalidOperationException e) { Assert.Fail(e.Message); } }