public void InvalidCommandTooManyCommandsTest() { // Arrange var m = new RoverClass(); var commands = "Left,10m,10m,10m,10m,10m,10m".Split(new char[] { ',' }); // Act var result = m.Movement(commands); // Assert Assert.AreEqual("41 East", result); }
public void OutOfBoundsNorthTest() { // Arrange var m = new RoverClass(); var commands = "Right,Right,10m".Split(new char[] { ',' }); // Act var result = m.Movement(commands); // Assert Assert.AreEqual("1 North", result); }
public void OutOfBoundsNorthTest2() { // Arrange var m = new RoverClass(); var commands = "20m,Left,20m,Left,66m".Split(new char[] { ',' }); // Act var result = m.Movement(commands); // Assert Assert.AreEqual("21 North", result); }
public void OutOfBoundsSouthTest() { // Arrange var m = new RoverClass(); var commands = "1m,2m,100m".Split(new char[] { ',' }); // Act var result = m.Movement(commands); // Assert Assert.AreEqual("9901 South", result); }
public void OutOfBoundsEastTest() { // Arrange var m = new RoverClass(); var commands = "Left,200m".Split(new char[] { ',' }); // Act var result = m.Movement(commands); // Assert Assert.AreEqual("100 East", result); }
public void MoveWestTest() { // Arrange var m = new RoverClass(); var commands = "Left,10m,Left,Left,5m".Split(new char[] { ',' }); // Act var result = m.Movement(commands); // Assert Assert.AreEqual("6 West", result); }
public void DistanceCommandsMultipleMovementTest() { // Arrange var m = new RoverClass(); var commands = "1m,2m,3m,4m,5m".Split(new char[] { ',' }); // Act var result = m.Movement(commands); // Assert Assert.AreEqual("1501 South", result); }
public void MoveSouthTest() { // Arrange var m = new RoverClass(); var commands = "2m".Split(new char[] { ',' }); // Act var result = m.Movement(commands); // Assert Assert.AreEqual("201 South", result); }
public void DistanceCommandsNoMovementTest() { // Arrange var m = new RoverClass(); var commands = "0m,0m,0m".Split(new char[] { ',' }); // Act var result = m.Movement(commands); // Assert Assert.AreEqual("1 South", result); }
public void DirectionalCommandsMultipleTurnRightsTest() { // Arrange var m = new RoverClass(); var commands = "Right,Right,Right,Right,Right".Split(new char[] { ',' }); // Act var result = m.Movement(commands); // Assert Assert.AreEqual("1 West", result); }
public void DirectionalCommandsTurnLeftTurnRightTest() { // Arrange var m = new RoverClass(); var commands = "Left,Right".Split(new char[] { ',' }); // Act var result = m.Movement(commands); // Assert Assert.AreEqual("1 South", result); }
public void DirectionalCommandsTurnRightTest() { // Arrange var m = new RoverClass(); var commands = new string[] { "Right" }; // Act var result = m.Movement(commands); // Assert Assert.AreEqual("1 West", result); }
public void GivenExampleTest() { // Arrange var m = new RoverClass(); var commands = "50m,Left,23m,Left,4m".Split(new char[] { ',' }); // Act var result = m.Movement(commands); // Assert Assert.AreEqual("4624 North", result); }
public void MultipleCommandSetsTest() { // Arrange var m = new RoverClass(); var commands1 = "10m,Right,Right,5m".Split(new char[] { ',' }); var commands2 = "1m".Split(new char[] { ',' }); // Act var result1 = m.Movement(commands1); var result2 = m.Movement(commands2); // Assert Assert.AreEqual("501 North", result1); Assert.AreEqual("401 North", result2); }
private string GetImages(DateTime queryDate) { try { RoverObject rover; rover = new RoverClass().QueryRoverObject(queryDate); StringBuilder sb = new StringBuilder(); string img; sb.AppendLine("<table border = '1'>"); foreach (Photo item in rover.photos) { sb.AppendLine("<tr>"); sb.AppendLine("<td>Date</td>"); sb.AppendLine(string.Format("<td>{0}</td>", item.earth_date)); sb.AppendLine("</tr>"); sb.AppendLine("<tr>"); sb.AppendLine("<td>ID</td>"); sb.AppendLine(string.Format("<td>{0}</td>", item.id)); sb.AppendLine("</tr>"); sb.AppendLine("<tr>"); sb.AppendLine("<td>Rover</td>"); sb.AppendLine(string.Format("<td>{0}</td>", item.rover.name)); sb.AppendLine("</tr>"); sb.AppendLine("<tr>"); sb.AppendLine("<td>Camera</td>"); sb.AppendLine(string.Format("<td>{0}</td>", item.camera.full_name)); sb.AppendLine("</tr>"); sb.AppendLine("<tr>"); img = "<img src = '{0}' alt = '{1}' style = 'max-width:500px;' />"; img = string.Format(img, item.img_src, item.earth_date); sb.AppendLine(string.Format("<td valign = 'top'>Image</td><td>{0}</td>", img)); sb.AppendLine("</tr>"); } sb.AppendLine("</table>"); return(sb.ToString()); } catch (Exception ex) { return(string.Format("An error has been encountered: {0}", ex.Message)); } }