示例#1
0
        public async Task move_should_stop_at_the_edge_of_the_garden(char orientation, int expectedY, int expectedX)
        {
            IPosition setting = new DevicePosition(5, 5, orientation) as IPosition;

            _initialSettingsMock.Setup(x => x.DevicePosition).Returns(setting);
            _buffer = new DeviceBuffer();
            _device = new SLMMDevice(_initialSettingsMock.Object, _buffer, _actuator);

            var position = _device.CurrentPosition();

            _device.Move();
            _device.Move();
            _device.Move();
            _device.Move();
            _device.Move();
            _device.Move();
            _device.Move();
            _device.Move();
            _device.Move();
            IPosition newPosition = await _device.Move();

            Assert.AreEqual(expectedY, newPosition.YAxis);
            Assert.AreEqual(expectedX, newPosition.XAxis);
            Assert.AreEqual(orientation, newPosition.Orientation);
        }
示例#2
0
        public async Task receive_move_instructions_and_buffer_them_for_execution()
        {
            var actuator = new TestsActuator(true);

            _device = new SLMMDevice(_initialSettingsMock.Object, _buffer, actuator);

            // act

            var watch = System.Diagnostics.Stopwatch.StartNew();

            _device.Move();
            _device.Move();
            _device.Move();
            var position = await _device.Move();

            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds;

            // assert
            Assert.GreaterOrEqual(elapsedMs, 5000 * 4);
            Assert.LessOrEqual(elapsedMs, 6000 * 4);
        }
示例#3
0
        public async Task move_two_step_forward(char orientation, int expectedY, int expectedX)
        {
            // garden: 0 x 0 -> 10 x 10
            // starts at: 'N', y:5, x:5
            // expects: 'N', y + 1 = 6, x

            IPosition setting = new DevicePosition(5, 5, orientation) as IPosition;

            _initialSettingsMock.Setup(x => x.DevicePosition).Returns(setting);
            _buffer = new DeviceBuffer();
            _device = new SLMMDevice(_initialSettingsMock.Object, _buffer, _actuator);

            var position = _device.CurrentPosition();

            IPosition newPosition = await _device.Move();

            newPosition = await _device.Move();

            Assert.AreEqual(expectedY, newPosition.YAxis);
            Assert.AreEqual(expectedX, newPosition.XAxis);
            Assert.AreEqual(orientation, newPosition.Orientation);
        }