public async Task Validate() { Validation = new ValidationScope() { IsValid = false }; ValidationResult commandValidation = ValidateCommand(); if (Entity.IsOriginAccountEqualsDestinationAccount()) { Validation.Message = "Operação inválida"; } else { if (commandValidation.IsValid) { Response databaseValidation = await ValidateInPersistenceLayer(); if (databaseValidation.Status) { Entity.From = await _accountRepository.Find(Entity.From.BankBranch, Entity.From.BankAccount); Entity.To = await _accountRepository.Find(Entity.To.BankBranch, Entity.To.BankAccount); ValidationResult domainValidation = ValidateInDomain(); if (domainValidation.IsValid) { Validation.IsValid = true; } else { Validation.Message = domainValidation.Errors.First().ErrorMessage; } } else { Validation.Message = databaseValidation.Message; } } else { Validation.Message = commandValidation.Errors.First().ErrorMessage; } } }
public async Task FindAccountByBranchAndAccountNumber_ShouldBeSuccess() { // Arrange var bankBranch = 1; var bankAccount = 1; var originAccountDto = GetCustomerAccountDto(bankAccount); var request = new CustomerAccountQuery(bankBranch, bankAccount); _customerAccountRepository.Find(Arg.Any <int>(), Arg.Any <int>()).Returns(_mapper.Map <CustomerAccount>(originAccountDto)); // Action var transfer = await _sut.Handle(request, new CancellationToken()).ConfigureAwait(false); // Assert Assert.IsTrue(transfer.IsSuccess); }
public async Task FindAccountTransfers_ShouldBeSuccess() { // Arrange var bankBranch = 1; var bankAccount = 1; var request = new AccountTransferQuery(bankBranch, bankAccount); _customerAccountRepository.Find(Arg.Any <int>(), Arg.Any <int>()).Returns(new CustomerAccount()); _transferRepository.FindAllOriginAccount(Arg.Any <CustomerAccount>()).Returns(new List <Transfer>()); // Action var transfer = await _sut.Handle(request, new CancellationToken()).ConfigureAwait(false); // Assert Assert.IsTrue(transfer.IsSuccess); }