예제 #1
0
        public async Task TestUpdate()
        {
            _serviceMock = new Mock <ICurrentAccountService>();
            _serviceMock.Setup(m => m.Insert(entity)).ReturnsAsync(Id);
            _service = _serviceMock.Object;

            var resultId = await _service.Insert(entity);

            Assert.False(resultId == Guid.Empty);

            _serviceMock = new Mock <ICurrentAccountService>();
            _serviceMock.Setup(m => m.UpdateDeposit(depositDto, UserId)).ReturnsAsync(currentAccountDtoResultDeposit);
            _service = _serviceMock.Object;

            var resultUpdateDeposit = await _service.UpdateDeposit(depositDto, UserId);

            Assert.NotNull(resultUpdateDeposit);
            Assert.Equal(Balance + depositDto.Value, resultUpdateDeposit.Balance);
            Assert.Equal(UserId, resultUpdateDeposit.UserId);

            _serviceMock = new Mock <ICurrentAccountService>();
            _serviceMock.Setup(m => m.UpdatePayment(paymentDto, UserId)).ReturnsAsync(currentAccountDtoResultPayment);
            _service = _serviceMock.Object;

            var resultUpdatePayment = await _service.UpdatePayment(paymentDto, UserId);

            Assert.NotNull(resultUpdatePayment);
            Assert.Equal(Balance - paymentDto.Value, resultUpdatePayment.Balance);
            Assert.Equal(UserId, resultUpdatePayment.UserId);

            _serviceMock = new Mock <ICurrentAccountService>();
            _serviceMock.Setup(m => m.UpdateTransfer(transferDto, UserId)).ReturnsAsync(currentAccountDtoResultTransfer);
            _service = _serviceMock.Object;

            var resultUpdateTransfer = await _service.UpdateTransfer(transferDto, UserId);

            Assert.NotNull(resultUpdatePayment);
            Assert.Equal(Balance - transferDto.Value, resultUpdateTransfer.Balance);
            Assert.Equal(UserId, resultUpdateTransfer.UserId);

            _serviceMock = new Mock <ICurrentAccountService>();
            _serviceMock.Setup(m => m.UpdateWithdraw(withdrawDto, UserId)).ReturnsAsync(currentAccountDtoResultWithdraw);
            _service = _serviceMock.Object;

            var resultUpdateWithdraw = await _service.UpdateWithdraw(withdrawDto, UserId);

            Assert.NotNull(resultUpdatePayment);
            Assert.Equal(Balance - withdrawDto.Value, resultUpdateWithdraw.Balance);
            Assert.Equal(UserId, resultUpdateWithdraw.UserId);
        }
예제 #2
0
        public async Task TestInsert()
        {
            _serviceMock = new Mock <ICurrentAccountService>();
            _serviceMock.Setup(m => m.Insert(entity)).ReturnsAsync(Id);
            _service = _serviceMock.Object;

            var resultId = await _service.Insert(entity);

            Assert.False(resultId == Guid.Empty);

            _serviceMockHistoric = new Mock <IHistoricCurrentAccountService>();
            _serviceMockHistoric.Setup(m => m.Insert(entityHistoric)).ReturnsAsync(HistoricCurrentAccountId);
            _serviceHistoric = _serviceMockHistoric.Object;

            var historicResultId = await _serviceHistoric.Insert(entityHistoric);

            Assert.False(historicResultId == Guid.Empty);
        }