示例#1
0
        public void Test_UpdateIncome_Fail_IncomeRecordNotFound()
        {
            _incomeRepository.Setup(i => i.GetIncomeByIncomeId(It.IsAny <long>()));

            var incomeServices = new BudgetIncomeServices(_incomeRepository.Object);

            Assert.ThrowsAsync <Exception>(() => incomeServices.UpdateIncome(1, 2));

            _incomeRepository.Verify(i => i.UpdateIncome(It.IsAny <long>(), It.IsAny <decimal>()), Times.Never);
        }
示例#2
0
        public async Task Test_UpdateIncome_Success()
        {
            _incomeRepository.Setup(i => i.GetIncomeByIncomeId(It.IsAny <long>()))
            .ReturnsAsync(new BudgetIncome());
            _incomeRepository.Setup(i => i.UpdateIncome(It.IsAny <long>(), It.IsAny <decimal>()))
            .Returns(Task.CompletedTask);

            var incomeServices = new BudgetIncomeServices(_incomeRepository.Object);
            await incomeServices.UpdateIncome(1, 2);

            _incomeRepository.Verify(i => i.UpdateIncome(It.IsAny <long>(), It.IsAny <decimal>()), Times.Once);
        }