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); }
public void Test_AddNewIncome_Fail_IncomeNotProvided() { var incomeServices = new BudgetIncomeServices(_incomeRepository.Object); Assert.ThrowsAsync <ArgumentException>(() => incomeServices.AddNewIncome(null)); _incomeRepository.Verify(i => i.AddNewIncome(It.IsAny <BudgetIncome>()), Times.Never); }
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); }
public void Test_GetAllIncomeByUserId_Fail_IncomeRecordsNotFound() { _incomeRepository.Setup(i => i.GetAllIncomeByUserId(It.IsAny <long>())); var incomeServices = new BudgetIncomeServices(_incomeRepository.Object); Assert.ThrowsAsync <Exception>(() => incomeServices.GetAllIncomeByUserId(1)); _incomeRepository.Verify(i => i.GetAllIncomeByUserId(It.IsAny <long>()), Times.Once); }
public async Task Test_GetAllIncomeByUserId_Success() { _incomeRepository.Setup(i => i.GetAllIncomeByUserId(It.IsAny <long>())) .ReturnsAsync(new List <BudgetIncome>()); var incomeServices = new BudgetIncomeServices(_incomeRepository.Object); await incomeServices.GetAllIncomeByUserId(1); _incomeRepository.Verify(i => i.GetAllIncomeByUserId(It.IsAny <long>()), Times.Once); }
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); }
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); }
public async Task Test_AddNewIncome_Success() { _incomeRepository.Setup(i => i.AddNewIncome(It.IsAny <BudgetIncome>())) .Returns(Task.CompletedTask); var incomeServices = new BudgetIncomeServices(_incomeRepository.Object); await incomeServices.AddNewIncome(new BudgetIncomeModel() { UserId = 1, Amount = 5, IncomeType = "Pay Check" }); _incomeRepository.Verify(i => i.AddNewIncome(It.IsAny <BudgetIncome>()), Times.Once); }
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); }