Beispiel #1
0
        public void Movement_Service_Start_With_Initialize_Should_Return_Correct_Result2()
        {
            var moveAreaMock = new Mock <IMoveArea <int> >();

            moveAreaMock.SetupGet(s => s.Width).Returns(10);
            moveAreaMock.SetupGet(s => s.Height).Returns(10);
            var robo    = new Robo <int, int>(moveAreaMock.Object);
            var service = new MovementService <int, int>(robo);

            robo.Step = 1;

            service.Initialize("PLACE 1,2,EAST");
            service.ProcessCommand("MOVE");
            service.ProcessCommand("MOVE");
            service.ProcessCommand("LEFT");
            service.ProcessCommand("MOVE");

            var expectedDirection = DirectionFactory <int, int> .Create("NORTH");

            robo.Direction.GetType().Should().BeSameAs(expectedDirection.GetType());
            robo.Position.X.Should().Be(3);
            robo.Position.Y.Should().Be(3);

            service.ProcessCommand("MOVE");
            robo.Position.X.Should().Be(3);
            robo.Position.Y.Should().Be(4);
        }
Beispiel #2
0
        public void Movement_Service_Start_Without_Initialize_Should_Throw_Exceptions(string command, string exceptionMessage)
        {
            var moveAreaMock = new Mock <IMoveArea <int> >();

            moveAreaMock.SetupGet(s => s.Width).Returns(10);
            moveAreaMock.SetupGet(s => s.Height).Returns(10);
            var robo    = new Robo <int, int>(moveAreaMock.Object);
            var service = new MovementService <int, int>(robo);

            Action act = () => service.ProcessCommand(command);

            act.Should().Throw <InvalidOperationException>().WithMessage(exceptionMessage);
        }