Exemplo n.º 1
0
        public async Task TransferBetweenAccounts_TheTwoAccountsAreEquals_ShouldBeFalse()
        {
            // Arrange
            var originAccountDto = GetOriginAccount();
            var transferDto      = BuildTransferDto(5, originAccountDto, originAccountDto);

            var request = new TransferCommandRequest(transferDto, 0);

            // Action
            var transfer = await _sut.Handle(request, new CancellationToken()).ConfigureAwait(false);

            // Assert
            Assert.IsFalse(transfer.IsSuccess);
        }
Exemplo n.º 2
0
        public void MakeTransf_Success_Result()
        {
            var makeTransfRequest = new TransferCommandRequest() { AccountIdTo=Guid.Parse("0a6dc873-21a5-42a4-a5e8-4a78a05ea059"), AccountIdFrom = Guid.Parse("f9fb6c56-e340-47be-92d5-a1ab7d3985db"),Amount= 111.2M };
            Mediator.Setup(x => x.Send(It.IsAny<TransferCommandRequest>(), new CancellationToken())).
                ReturnsAsync(new TransferCommandResponse() { AccountIdTo = Guid.Parse("0a6dc873-21a5-42a4-a5e8-4a78a05ea059"), AccountIdFrom = Guid.Parse("f9fb6c56-e340-47be-92d5-a1ab7d3985db"), BalanceAccountFrom = 121.2M, BalanceAccountTo=90.9M });


            var orderController = new AccountController(Mediator.Object);

            //Action
            var result = orderController.Transfer(makeTransfRequest);

            //Assert
            Assert.NotNull(result);
        }
Exemplo n.º 3
0
        public async Task TransferBetweenAccounts_TheBalanceIsInsufficient_ShouldBeFalse()
        {
            // Arrange
            var originAccountDto = GetOriginAccount();
            var transferDto      = BuildTransferDto(40, originAccountDto, GetDestinationAccount());

            var request = new TransferCommandRequest(transferDto, 0);

            _unitOfWork.CustomerAccount.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.IsFalse(transfer.IsSuccess);
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Transfer([FromBody] TransferCommandRequest Command)
        {
            var commandResult = await _mediator.Send(Command);

            return(Ok(commandResult));
        }