public void ShouldMoveRoversCorrectly() { Stream stream = null; try { stream = new MemoryStream(); using (StreamWriter writer = new StreamWriter(stream)) { stream = null; writer.WriteLine("5 5"); writer.WriteLine("1 2 N"); writer.WriteLine("LMLMLMLMM"); writer.WriteLine("3 3 E"); writer.WriteLine("MMRMMRMRRM"); writer.Flush(); writer.BaseStream.Position = 0; var controller = new RoverController(writer.BaseStream); var result = controller.RoverPositions(); result.ShouldEqual("1 3 N\r\n5 1 E\r\n"); } } finally { if (stream != null) { stream.Dispose(); } } }