public async Task Test(int param) { await Task.WhenAll(_handler1.ReturnToOriginAsync(), _handler2.ReturnToOriginAsync()); var positions = await Task.WhenAll(_handler1.GetPositionAsync(), _handler2.GetPositionAsync()); CollectionAssert.AreEquivalent(new[] { 0, 0 }, positions); var responses = await Task.WhenAll( _handler1.SendCommandAsync(Command.MoveToPosition, param, CommandParam.MoveType.Absolute), _handler2.SendCommandAsync(Command.MoveToPosition, param, CommandParam.MoveType.Absolute)); CollectionAssert.AreEquivalent(new[] { true, true }, responses.Select(x => x.Status == ReturnStatus.Success)); await Task.WhenAll(_handler1.WaitForPositionReachedAsync(), _handler2.WaitForPositionReachedAsync()); positions = await Task.WhenAll(_handler1.GetPositionAsync(), _handler2.GetPositionAsync()); CollectionAssert.AreEquivalent(new[] { param, param }, positions); await Task.WhenAll(_handler1.ReturnToOriginAsync(), _handler2.ReturnToOriginAsync()); positions = await Task.WhenAll(_handler1.GetPositionAsync(), _handler2.GetPositionAsync()); CollectionAssert.AreEquivalent(new[] { 0, 0 }, positions); }
public async Task Test_Status() { await _motor.WaitForPositionReachedAsync(); var status = await _motor.GetStatusAsync(); var axisStatus = await _motor.GetRotationStatusAsync(); var equivalence = status.Join(axisStatus, x => x.Key, y => y.Key, (x, y) => x.Value == y.Value) .All(x => x); var isReached = await _motor.IsTargetPositionReachedAsync(); Assert.IsTrue(equivalence); Assert.IsTrue(isReached); }