public async Task CategoryExpenseAdd_TryingAddNewObjectToDB_ShouldBeAbleReturnIdEquals8()
        {
            // Arrange
            mockMapper.Setup(x => x.Map <List <Entities.CategoryExpense> >(It.IsAny <List <Models.CategoryExpense> >()))
            .Returns(It.IsAny <List <Entities.CategoryExpense> >());
            mockRepo.Setup(y => y.AddRangeAsync(It.IsAny <IEnumerable <Entities.CategoryExpense> >()))
            .Returns(() => Task.Run(() => { return(true); })).Verifiable();
            mockRepo.Setup(y => y.SaveAsync())
            .Returns(() => Task.Run(() => { return(true); })).Verifiable();
            categoryExpenseEntityLists = new List <Entities.CategoryExpense>
            {
                new Entities.CategoryExpense {
                    Id = 8, Description = "New category Expense was added"
                }
            };
            var sut = new CategoryExpenseService(mockRepo.Object, mockMapper.Object);

            // Act
            var resultOfAddCategoryExpense = await sut.AddCategoryExpense(categoryExpenseModelLists);

            await context.CategoryExpenses.AddRangeAsync(categoryExpenseEntityLists);

            await context.SaveChangesAsync();

            var isAddedNewObject = queryDBInMemory.GetAsync(8);

            // Assert
            Assert.AreEqual(8, isAddedNewObject.Result.Id, "New object was not added, require id=8");
            Assert.IsTrue(resultOfAddCategoryExpense, "Add and Save should return true. Object i added to Database");
            mockRepo.Verify(
                x => x.AddRangeAsync(It.IsAny <IEnumerable <Entities.CategoryExpense> >()),
                Times.Once, "AddRangeAsync should run once");
            mockRepo.Verify(
                x => x.SaveAsync(), Times.Once, "SaveAsync should run once");
        }
        public async Task AddCategoryExpense_ShouldRunAddRangeAsyncOnlyOnce()
        {
            // Arrange
            mockMapper.Setup(x => x.Map <List <Entities.CategoryExpense> >(It.IsAny <List <Models.CategoryExpense> >()))
            .Returns(It.IsAny <List <Entities.CategoryExpense> >());
            mockRepo.Setup(y => y.AddRangeAsync(It.IsAny <IEnumerable <Entities.CategoryExpense> >()))
            .Returns(() => Task.Run(() => { })).Verifiable();

            var sut = new CategoryExpenseService(mockRepo.Object, mockMapper.Object);

            // Act
            await sut.AddCategoryExpense(categoryExpenseModelLists);

            // Assert
            mockRepo.Verify(
                x => x.AddRangeAsync(It.IsAny <IEnumerable <Entities.CategoryExpense> >()),
                Times.Once, "AddRangeAsync should run once");
        }
        public async Task AddCategoryExpense_ShouldNotBeAbleToAddCategoryExpense()
        {
            // Arrange
            mockMapper.Setup(x => x.Map <List <Entities.CategoryExpense> >(It.IsAny <List <Models.CategoryExpense> >()))
            .Returns(It.IsAny <List <Entities.CategoryExpense> >());
            mockRepo.Setup(y => y.AddRangeAsync(It.IsAny <IEnumerable <Entities.CategoryExpense> >()))
            .Returns(() => Task.Run(() => { return(true); })).Verifiable();
            mockRepo.Setup(y => y.SaveAsync())
            .Returns(() => Task.Run(() => { return(false); })).Verifiable();

            var sut = new CategoryExpenseService(mockRepo.Object, mockMapper.Object);

            // Act
            var resultOfAddCategoryExpense = await sut.AddCategoryExpense(categoryExpenseModelLists);

            // Assert
            Assert.IsFalse(resultOfAddCategoryExpense, "Save should return false");
            mockRepo.Verify(
                x => x.AddRangeAsync(It.IsAny <IEnumerable <Entities.CategoryExpense> >()), Times.Once, "AddRangeAsync should run once");
            mockRepo.Verify(
                x => x.SaveAsync(), Times.Once, "SaveAsync should run once");
        }