public async Task MoveUpAsyncShouldMoveElevatorUpwards() { var request = new ElevatorRequest { FromFloor = 0, ToFloor = 5 }; var elevator = new Elevator { CurrentFloor = 0, Name = nameof(MoveDownAsyncShouldMoveElevatorDownwards) }; var elevatorMover = new ElevatorMover( elevator, _movementLogger.Object, _waiterService.Object ); await elevatorMover.MoveUpAsync(request); Assert.Equal(request.ToFloor, elevator.CurrentFloor); }
public async Task MoveUpAsyncShouldAbortIfCanceled() { var cts = new CancellationTokenSource(); var request = new ElevatorRequest { FromFloor = 0, ToFloor = 5 }; var elevator = new Elevator { CurrentFloor = 0, Name = nameof(MoveDownAsyncShouldMoveElevatorDownwards) }; var elevatorMover = new ElevatorMover( elevator, _movementLogger.Object, new WaiterService() ); cts.Cancel(); await Assert.ThrowsAsync <TaskCanceledException>(() => elevatorMover.MoveUpAsync(request, cts.Token) ); }