コード例 #1
0
        public void WhenGetPositionAndStateWithCommandNull()
        {
            var mockCommand            = new Mock <ICommand>();
            var mockRobot              = new Mock <IRobot>();
            var mockCalculator         = new Mock <ICalculator>();
            var leftPositionCalculator = new LeftPositionCalculator(mockRobot.Object, mockCalculator.Object);

            Assert.Throws <ArgumentException>(() => leftPositionCalculator.GetPositionAndState(null));
        }
コード例 #2
0
        public void WhenGetPositionAndStateWithCommandLeftFacingSouth()
        {
            var command   = new Left();
            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 leftPositionCalculator = new LeftPositionCalculator(mockRobot.Object, mockCalculator.Object);
            var result = leftPositionCalculator.GetPositionAndState(command);

            Assert.Equal(Direction.East, result.position.Direction);
        }
コード例 #3
0
        public void WhenProcessReportCommand()
        {
            var mockRobot = new Mock <IRobot>();

            mockRobot.Setup(r => r.GetReport());
            mockRobot.SetupGet(r => r.CurrentPosition).Returns(new Position(new Location(1, 1), Direction.West));
            var mockCalculator         = new Mock <ICalculator>();
            var leftPositionCalculator = new LeftPositionCalculator(mockRobot.Object, mockCalculator.Object);

            leftPositionCalculator.ProcessReportCommand();
            mockRobot.Verify(r => r.GetReport());
        }
コード例 #4
0
        public void WhenGetPositionAndStateWithCommandNonLeft()
        {
            var command   = new Right();
            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 leftPositionCalculator = new LeftPositionCalculator(mockRobot.Object, mockCalculator.Object);
            var result = leftPositionCalculator.GetPositionAndState(command);

            mockCalculator.Verify(c => c.GetPositionAndState(It.IsAny <ICommand>()));
        }