public void Should_ThrowArgumentNullException_When_InputToDefineIsNull() { //Act var action = new Action(() => Plateau.Define(null)); //Assert action.Should().ThrowExactly <ArgumentNullException>(); }
public void Should_ThrowArgumentException_When_CoordinateToDefineIsInvalid(string coordinates) { //Act var action = new Action(() => Plateau.Define(coordinates)); //Assert action.Should().Throw <ArgumentException>(); }
public void When_size_has_been_set_returns_size_with_same_values(int expectedWidth, int expectedHeight) { var expectedSize = new Size(expectedWidth, expectedHeight); var plateau = new Plateau(); plateau.Define(expectedWidth, expectedHeight); var actualSize = plateau.GetSize(); Assert.AreEqual(expectedSize, actualSize); }
public void Should_ThrowArgumentException_When_UpperCoordinatesToDefinePlateauAreInvalid() { //Arrange const string coordinates = "-5 -5"; //Act var action = new Action(() => Plateau.Define(coordinates)); //Assert action.Should().Throw <ArgumentException>(); }
public void Should_ThrowArgumentException_When_LocationToDeployIsInvalid(string position) { //Arrange const string coordinates = "5 5"; var plateau = Plateau.Define(coordinates); //Act var action = new Action(() => plateau.Deploy(position)); //Assert action.Should().Throw <ArgumentException>(); }
public void Should_ThrowArgumentNullException_When_InputToDeployIsNull() { //Arrange const string coordinates = "5 5"; var plateau = Plateau.Define(coordinates); //Act var action = new Action(() => plateau.Deploy(null)); //Assert action.Should().ThrowExactly <ArgumentNullException>(); }
public void Should_MatchUpperCoordinates_When_InputToDefineIsValid() { //Arrange const int x = 5; const int y = 5; var coordinates = MapFlat(x, y); //Act var plateau = Plateau.Define(coordinates); //Assert plateau.Surface.Width.Should().Be(x); plateau.Surface.Height.Should().Be(y); }
public void Should_ThrowRoverPositionOutsidePlateauException_When_DeployingOutsideBoundaries(int x, int y, CardinalPoint cardinalPoint) { //Arrange const string coordinates = "5 5"; var plateau = Plateau.Define(coordinates); var position = MapFlat(x, y, cardinalPoint); //Act var action = new Action(() => plateau.Deploy(position)); //Assert action.Should().Throw <RoverPositionOutsidePlateauException>(); }
public void Should_ThrowArgumentException_When_InstructionToExploreIsInvalid(string instructions) { //Arrange const string coordinates = "5 5"; var plateau = Plateau.Define(coordinates); const string position = "1 2 N"; plateau.Deploy(position); //Act var action = new Action(() => plateau.Explore(instructions)); //Assert action.Should().Throw <ArgumentException>(); }
public void Should_LandEachRoverSequentially_When_DeployingInsideBoundaries() { //Arrange const string coordinates = "5 5"; var plateau = Plateau.Define(coordinates); const string position1 = "1 2 N"; const string position2 = "3 3 E"; //Act var rover1 = plateau.Deploy(position1); var rover2 = plateau.Deploy(position2); //Assert plateau.TotalRovers.Should().Be(2); plateau.Squad[0].Should().Be(rover1); plateau.Squad[plateau.TotalRovers - 1].Should().Be(rover2); }
public void Should_ThrowRoverPositionOutsidePlateauException_When_ExploringOutsideBoundaries() { //Arrange const string coordinates = "5 5"; var plateau = Plateau.Define(coordinates); const string position = "1 2 N"; plateau.Deploy(position); const string instructions = "LMM"; //Act var action = new Action(() => plateau.Explore(instructions)); //Assert action.Should().Throw <RoverPositionOutsidePlateauException>(); }
public void Should_LandRover_When_DeployingInsideBoundaries() { //Arrange const string coordinates = "5 5"; var plateau = Plateau.Define(coordinates); const int x = 1; const int y = 2; const CardinalPoint cardinalPoint = CardinalPoint.N; var position = MapFlat(x, y, cardinalPoint); //Act var rover = plateau.Deploy(position); //Assert plateau.Squad[plateau.TotalRovers - 1].Should().Be(rover); rover.Position.X.Should().Be(x); rover.Position.Y.Should().Be(y); rover.Position.CardinalPoint.Should().Be(cardinalPoint); }
public void Should_NavigateLastDeployedRover_When_Exploring() { //Arrange const string coordinates = "5 5"; var plateau = Plateau.Define(coordinates); const string position1 = "1 2 N"; const string instructions1 = "LMLMLMLMM"; const string position2 = "3 3 E"; const string instructions2 = "MMRMMRMRRM"; //Act var rover1 = plateau.Deploy(position1); rover1 = plateau.Explore(instructions1); var rover2 = plateau.Deploy(position2); rover2 = plateau.Explore(instructions2); //Assert rover1.Position.Equals(new Position(1, 3, CardinalPoint.N)); rover2.Position.Equals(new Position(5, 1, CardinalPoint.E)); }