public void WhenGetPositionAndStateWithCommandNull() { var mockCommand = new Mock <ICommand>(); var mockRobot = new Mock <IRobot>(); var mockCalculator = new Mock <ICalculator>(); var rightPositionCalculator = new RightPositionCalculator(mockRobot.Object, mockCalculator.Object); Assert.Throws <ArgumentException>(() => rightPositionCalculator.GetPositionAndState(null)); }
public void WhenGetPositionAndStateWithCommandRightFacingSouth() { var command = new Right(); var mockRobot = new Mock <IRobot>(); mockRobot.SetupGet(r => r.CurrentPosition).Returns(new Position(new Location(1, 1), Direction.South)); var mockCalculator = new Mock <ICalculator>(); var rightPositionCalculator = new RightPositionCalculator(mockRobot.Object, mockCalculator.Object); var result = rightPositionCalculator.GetPositionAndState(command); Assert.Equal(Direction.West, result.position.Direction); }
public void WhenGetPositionAndStateWithCommandNonRight() { var command = new Left(); var mockRobot = new Mock <IRobot>(); mockRobot.SetupGet(r => r.CurrentPosition).Returns(new Position(new Location(1, 1), Direction.West)); var mockCalculator = new Mock <ICalculator>(); mockCalculator.Setup(c => c.GetPositionAndState(It.IsAny <ICommand>())); var rightPositionCalculator = new RightPositionCalculator(mockRobot.Object, mockCalculator.Object); var result = rightPositionCalculator.GetPositionAndState(command); mockCalculator.Verify(c => c.GetPositionAndState(It.IsAny <ICommand>())); }