public void MoveMowerToAValidCell(int gardenLength, int gardenWidth, int startX, int startY, Orientation orientation, int expectedX, int expectedY) { var context = new MoveMowerTestContext(); "Given I have a garden" .x(() => context.Garden = new Garden(gardenLength, gardenWidth)); "And I have started a new Mower inside the garden" .x(() => context.Mower = this.CreateNewMower(context.Garden, startX, startY, orientation)); "When I move the Mower forward" .x(() => context.Mower.Move()); "Then its position should change as expected" .x(() => this.AssertPosition(context.Mower.GetPosition(), expectedX, expectedY, orientation)); }
public void TurnMower(int gardenLength, int gardenWidth, int startX, int startY, Orientation orientation, TurnDirection turnDirection, Orientation expectedOrientation) { var context = new MoveMowerTestContext(); Position currentPosition = new Position(new Coordinates(startX, startY), orientation); "Given I have a garden" .x(() => context.Garden = new Garden(gardenLength, gardenWidth)); "And I have started a new Mower inside the garden" .x(() => context.Mower = this.CreateNewMower(context.Garden, startX, startY, orientation)); "When I turn the Mower" .x(() => context.Mower.Turn(turnDirection)); "Then its orientation should be as expected" .x(() => context.Mower.GetPosition().Orientation.Should().Be(expectedOrientation)); }
public void GetPositionFromStartup(int gardenLength, int gardenWidth, int startX, int startY, Orientation orientation) { var context = new MoveMowerTestContext(); Position currentPosition = null; "Given I have a garden" .x(() => context.Garden = new Garden(gardenLength, gardenWidth)); "And I have started a new Mower inside the garden" .x(() => context.Mower = this.CreateNewMower(context.Garden, startX, startY, orientation)); "When I get the Mower's position" .x(() => currentPosition = context.Mower.GetPosition()); "Then it should be as I set it" .x(() => this.AssertPosition(currentPosition, startX, startY, orientation)); }
public void MoveMowerToAnInvalidCell(int gardenLength, int gardenWidth, int startX, int startY, Orientation orientation) { var context = new MoveMowerTestContext(); Action moveAction = null; Position currentPosition = new Position(new Coordinates(startX, startY), orientation); "Given I have a garden" .x(() => context.Garden = new Garden(gardenLength, gardenWidth)); "And I have started a new Mower inside the garden" .x(() => context.Mower = this.CreateNewMower(context.Garden, startX, startY, orientation)); "When I move the Mower forward" .x(() => moveAction = new Action(() => context.Mower.Move())); "Then its position should not change" .x(() => moveAction.Should().Throw <OutOfGardenBoundaryException>()); }