public void DoInstructions_ReturnCleanedPlaces_IfMoveFromOneBondToAnother() { // Arrange var office = new OfficeArea(); var robot = new RobotHoover(office, new CommandParser()); robot.SetStartPosition(-100000, 0); const int iterations = 2; // Act robot.SetStartPosition(-100000, 0); for (var i = 0; i < iterations; i++) { robot.DoInstruction($"E {office.MaxCoordinate}"); robot.DoInstruction($"E {office.MaxCoordinate}"); robot.DoInstruction("S 1"); robot.DoInstruction($"W {office.MaxCoordinate}"); robot.DoInstruction($"W {office.MaxCoordinate}"); robot.DoInstruction("S 1"); } // Assert const int initialPosition = 1; var command1 = office.MaxCoordinate * 2 + 1; var command2 = office.MaxCoordinate * 2 + 1; var expectedCleanedPlaces = (command1 + command2) * iterations + initialPosition; office.CleanedPlaces.Should().Be(expectedCleanedPlaces); }
public void SetStartPosition_StorePosition_IfStepOutOfBonds(int x, int y, int expectedX, int expectedY) { // Arrange var office = new OfficeArea(); var robot = new RobotHoover(office, new CommandParser()); // Act robot.SetStartPosition(x, y); // Assert robot.Position.X.Should().Be(expectedX); robot.Position.Y.Should().Be(expectedY); }
public void SetStartPosition_StorePosition_IfCellNotCleaned(int x, int y) { // Arrange var office = new OfficeArea(); var robot = new RobotHoover(office, new CommandParser()); // Act robot.SetStartPosition(x, y); // Assert robot.Position.X.Should().Be(x); robot.Position.Y.Should().Be(y); }
public void DoInstructions_ReturnCleanedPlaces_IfCall() { // Arrange var office = new OfficeArea(); var robot = new RobotHoover(office, new CommandParser()); robot.SetStartPosition(0, 0); const int stepsNumber = 5; // Act robot.DoInstruction($"E {stepsNumber}"); // Assert const int initialPosition = 1; const int command1 = stepsNumber; const int expectedCleanedPlaces = command1 + initialPosition; office.CleanedPlaces.Should().Be(expectedCleanedPlaces); }
public void SetStartPosition_SetInitialCoordinates_IfCall() { // Arrange const int x = 5; const int y = 10; office .Setup(_ => _.GetValidCoordinate(It.IsAny <int>())) .Returns((int c) => c); // Act robot.SetStartPosition(x, y); // Assert robot.Position.Should().NotBeNull(); robot.Position.X.Should().Be(x); robot.Position.Y.Should().Be(y); office.Verify(_ => _.GetValidCoordinate(x)); office.Verify(_ => _.GetValidCoordinate(y)); }