public async void Code_WhenAllThreeCharachtersAreUpperCaseLetters_ShouldNotHaveValidationError(string code) { A.CallTo(() => _cryptoCurrencyRepository.GetCryptoCurrencyByCodeAsync(code, default)).Returns <CryptoCurrency>(null); var request = new CryptoCurrencyAddRequest() { Code = code }; await _testee.ShouldNotHaveValidationErrorForAsync(x => x.Code, new AddCryptoCurrencyCommand(request)); }
public void MapAddCryptoCurrencyCommandToCryptoCurrency_ShouldreturnCorrectData(string code) { //arrange var request = new CryptoCurrencyAddRequest() { Code = code }; var command = new AddCryptoCurrencyCommand(request); //act var result = _mapper.MapAddCryptoCurrencyCommandToCryptoCurrency(command); //assert result.Code.Should().Be(code); result.Id.Should().Be(default);
public async void Code_WhenThreIsInDataBase_ShouldHaveValidationError(string code) { var respone = new CryptoCurrency() { Code = code }; A.CallTo(() => _cryptoCurrencyRepository.GetCryptoCurrencyByCodeAsync(code, default)).Returns(respone); var request = new CryptoCurrencyAddRequest() { Code = code }; (await _testee.ShouldHaveValidationErrorForAsync(x => x.Code, new AddCryptoCurrencyCommand(request))) .WithErrorMessage("The 'Code' already exist!"); }
public async Task <IActionResult> Create(CryptoCurrencyAddRequest request) { try { var command = new AddCryptoCurrencyCommand(request); var res = await _mediator.Send(command); if (res.HasError) { ViewBag.Errors = res.Errors; return(View()); } return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public AddCryptoCurrencyCommand(CryptoCurrencyAddRequest request) { this.Code = request.Code; }