public void Deposit_Should_ThrowValidationException_When_IbanNumberIsInvalid()
        {
            var dto = new StatementDepositDto
            {
                iban_number = "hello",
                amount      = 100
            };

            Assert.ThrowsAsync <ValidationException>(() => _testService.Deposit(dto));
        }
        public void Deposit_Should_ThrowValidationException_When_IbanNumberAlreadyExists()
        {
            var dto = new StatementDepositDto
            {
                iban_number = "NL13ABNA7035378898",
                amount      = 100
            };

            MockAccountRepository.Setup(x => x.HasAccount(It.IsAny <string>())).Returns(Task.FromResult(false));

            Assert.ThrowsAsync <ValidationException>(() => _testService.Deposit(dto));
        }
        public void Deposit_Should_Success_When_DtoIsValid()
        {
            var dto = new StatementDepositDto
            {
                iban_number = "NL13ABNA7035378898",
                amount      = 100
            };

            MockAccountRepository.Setup(x => x.HasAccount(It.IsAny <string>())).Returns(Task.FromResult(true));
            MockStatementRepository.Setup(x => x.Add(It.IsAny <Statement>())).Returns(Task.FromResult(new Statement()));

            var result = _testService.Deposit(dto).Result;

            Assert.IsNotNull(result);
        }
Exemple #4
0
        public async Task <StatementDto> Deposit(StatementDepositDto dto)
        {
            ValidationHelper.Validate(_statementDepositValidator, dto);
            var account = await _accountRepository.GetByIBanNumber(dto.iban_number);

            var statement = new Statement
            {
                Account       = account,
                Amount        = dto.amount,
                CreateAt      = DateTime.Now,
                Fee           = _appSettings.DepositFee,
                StatementType = Application.Enums.StatementType.Deposit
            };
            await _statementRepository.Add(statement);

            return(ConvertToDto(statement));
        }
Exemple #5
0
        public async Task <ActionResult <StatementDto> > Post(StatementDepositDto dto)
        {
            var viewDto = await _statementService.Deposit(dto);

            return(Ok(viewDto));
        }