public async Task <ValidateableResponse <CryptoCurrencyRawResponse> > Handle(AddCryptoCurrencyCommand request, CancellationToken cancellationToken)
        {
            var newCryptoCurrency = _mapper.MapAddCryptoCurrencyCommandToCryptoCurrency(request);
            var result            = await _cryptoCurrencyRepository.AddNewCryptoCurrencyAsync(newCryptoCurrency, cancellationToken);

            return(new ValidateableResponse <CryptoCurrencyRawResponse>(_mapper.MapCryptoCurrencyToCryptoCurrencyRawResponse(result)));
        }
Exemple #2
0
        public async void Handle_ShouldCallAddNewCryptoCurrencyAsync()
        {
            //arrange
            var request = new Contract.Requests.CryptoCurrencyAddRequest()
            {
                Code = "BTC"
            };
            var command           = new Application.CQRS.Commands.AddCryptoCurrencyCommand(request);
            var newCryptoCurrency = new CryptoCurrency()
            {
                Code = command.Code
            };

            A.CallTo(() => _mapper.MapAddCryptoCurrencyCommandToCryptoCurrency(command)).Returns(newCryptoCurrency);
            //act
            await _testee.Handle(command, default);

            //assert
            A.CallTo(() => _cryptoCurrencyRepository.AddNewCryptoCurrencyAsync(newCryptoCurrency, default)).MustHaveHappenedOnceExactly();
        }