Exemplo n.º 1
0
        public Task <Unit> Handle(StopPlayingSoundEffect request, CancellationToken cancellationToken)
        {
            _buzzer.StopPlaying();

            _logger.LogInformation("Sent stop playing request.");

            return(Unit.Task);
        }
Exemplo n.º 2
0
        public async Task Handle(MotionStopped motionStopped, CancellationToken cancellationToken)
        {
            _logger.LogDebug($"Received {motionStopped} event.");

            if (!Started)
            {
                return;
            }

            var command = new StopPlayingSoundEffect();
            await _mediator.Send(command);
        }
Exemplo n.º 3
0
        public async Task Handle_StopPlayingSoundEffect_stops_playing_sound_effect()
        {
            // Arrange
            var command = new StopPlayingSoundEffect();

            // Act
            await _sut.Handle(command, _defaultCancellationToken);

            // Assert
            A.CallTo(() => _buzzer.StopPlaying())
            .MustHaveHappenedOnceExactly();
        }
Exemplo n.º 4
0
        public async Task Handle(DistanceMeasured distanceMeasured, CancellationToken cancellationToken)
        {
            _logger.LogDebug($"Received {distanceMeasured} event.");

            var soundEffect = _distanceToSoundEffectConverter.DistanceToSoundEffect(distanceMeasured.Distance);

            IRequest command;

            if (soundEffect == null)
            {
                command = new StopPlayingSoundEffect();
            }
            else
            {
                command = new StartPlayingSoundEffect(soundEffect.Frequency);
            }

            await _mediator.Send(command);

            _logger.LogDebug($"Sent {command} command.");
        }