public void DeleteTest() { // Arrange var controller = new RoverController(); controller.Post(new CommandBody { Command = "5 5", Type = CommandType.SetupPlateau }); controller.Post(new CommandBody { Command = "1 2 N", Type = CommandType.SetupRover }); controller.Post(new CommandBody { Command = "LMLMLMLMM", Type = CommandType.Move }); var beforeCount = controller.Get().Count; // Act controller.Delete(); var afterCount = controller.Get().Count; // Assert Assert.IsTrue(beforeCount > 0, "Before count should be more than zero"); Assert.AreEqual(0, afterCount); }
public void GetTestWithId() { // Arrange var controller = new RoverController(); controller.Delete(); HistoryRecord expectedRecord1 = new HistoryRecord { Command = "0 0 -> 5 5", Input = false }; HistoryRecord expectedRecord2 = new HistoryRecord { Command = "5 1 E", Input = false }; HistoryRecord expectedRecord3 = null; // Act controller.Post(new CommandBody { Command = "5 5", Type = CommandType.SetupPlateau }); controller.Post(new CommandBody { Command = "1 2 N", Type = CommandType.SetupRover }); controller.Post(new CommandBody { Command = "LMLMLMLMM", Type = CommandType.Move }); controller.Post(new CommandBody { Command = "3 3 E", Type = CommandType.SetupRover }); controller.Post(new CommandBody { Command = "MMRMMRMRRM", Type = CommandType.Move }); var record1 = controller.Get(1); var record2 = controller.Get(9); var record3 = controller.Get(10); // Assert Assert.AreEqual(expectedRecord1, record1); Assert.AreEqual(expectedRecord2, record2); Assert.AreEqual(expectedRecord3, record3); }
public void GetAllRoversTest() { List <Rover> testRovers = DataContext.Rovers; RoverController controller = new RoverController(); List <Rover> result = controller.Get() as List <Rover>; Assert.AreEqual(testRovers.Count, result.Count); }
public void RoverController_ShouldReturnCorrectRover() { Guid id = new Guid("ac077fdf-ca63-45b2-9c63-74f73383d8c8"); Rover testRover = DataContext.Rovers.Where(p => p.Id == id).FirstOrDefault(); RoverController controller = new RoverController(); Rover result = controller.Get(id); Assert.IsNotNull(result); Assert.AreEqual(testRover.Name, result.Name); }
public void Get() { var result = _roverController.Get(1); Assert.IsNotNull(result); }
public void GetTest() { // Arrange var controller = new RoverController(); controller.Delete(); List <HistoryRecord> expectedHistory = new List <HistoryRecord> { new HistoryRecord { Command = "5 5", Input = true }, new HistoryRecord { Command = "0 0 -> 5 5", Input = false }, new HistoryRecord { Command = "1 2 N", Input = true }, new HistoryRecord { Command = "1 2 N", Input = false }, new HistoryRecord { Command = "LMLMLMLMM", Input = true }, new HistoryRecord { Command = "1 3 N", Input = false }, new HistoryRecord { Command = "3 3 E", Input = true }, new HistoryRecord { Command = "3 3 E", Input = false }, new HistoryRecord { Command = "MMRMMRMRRM", Input = true }, new HistoryRecord { Command = "5 1 E", Input = false } }; // Act controller.Post(new CommandBody { Command = "5 5", Type = CommandType.SetupPlateau }); controller.Post(new CommandBody { Command = "1 2 N", Type = CommandType.SetupRover }); controller.Post(new CommandBody { Command = "LMLMLMLMM", Type = CommandType.Move }); controller.Post(new CommandBody { Command = "3 3 E", Type = CommandType.SetupRover }); controller.Post(new CommandBody { Command = "MMRMMRMRRM", Type = CommandType.Move }); var history = controller.Get(); // Assert Assert.AreEqual(expectedHistory.Count, history.Count); for (int i = 0; i < history.Count; i++) { Assert.AreEqual(expectedHistory[i], history[i]); } }