Ejemplo n.º 1
0
        public void Test_UpsertIncomes_Fail_NullServiceParameter()
        {
            var incomeServices = new BudgetIncomeServices(_incomeRepository.Object);

            Assert.ThrowsAsync <NullReferenceException>(() => incomeServices.UpsertIncomes(null));
            _incomeRepository.Verify(i => i.UpsertIncomes(It.IsAny <List <BudgetIncome> >()), Times.Never);
        }
Ejemplo n.º 2
0
        public void Test_UpsertIncomes_Fail_EmptyList()
        {
            _incomeRepository.Setup(i => i.UpsertIncomes(It.IsAny <List <BudgetIncome> >()))
            .Returns(Task.CompletedTask);

            var incomeServices = new BudgetIncomeServices(_incomeRepository.Object);

            Assert.ThrowsAsync <ArgumentException>(() => incomeServices.UpsertIncomes(new List <BudgetIncomeModel>()));

            _incomeRepository.Verify(i => i.UpsertIncomes(It.IsAny <List <BudgetIncome> >()), Times.Never);
        }
Ejemplo n.º 3
0
        public async Task Test_UpsertIncomes_Success()
        {
            _incomeRepository.Setup(i => i.UpsertIncomes(It.IsAny <List <BudgetIncome> >()))
            .Returns(Task.CompletedTask);

            var incomeServices = new BudgetIncomeServices(_incomeRepository.Object);
            await incomeServices.UpsertIncomes(new List <BudgetIncomeModel>()
            {
                new BudgetIncomeModel {
                    UserId = 1, Amount = 300, IncomeType = "Rent"
                },
                new BudgetIncomeModel {
                    UserId = 1, Amount = 500, IncomeType = "Rent"
                }
            });

            _incomeRepository.Verify(i => i.UpsertIncomes(It.IsAny <List <BudgetIncome> >()), Times.Once);
        }