Ejemplo n.º 1
0
        public async Task RemoveCategoryIncome_ShouldBeAbleToRemoveOneObjectWithIdEquals1()
        {
            // Arrange
            categoryIncomeEntityObj = new Entities.CategoryIncome {
                Id = 1, Description = "description1"
            };

            mockRepo.Setup(y => y.GetAsync(It.IsAny <int>()))
            .Returns(Task.FromResult(categoryIncomeEntityObj));
            mockRepo.Setup(y => y.RemoveAsync(It.IsAny <Entities.CategoryIncome>()))
            .Returns(Task.FromResult(true));

            var sut       = new CategoryIncomeService(mockRepo.Object, null);
            var getEntity = await sut.GetAsync(1);

            // Act

            var isRemoved = await sut.RemoveAsync(getEntity);

            // Assert
            Assert.AreEqual(1, getEntity.Id, "GetAsync doesn't return correct Object");
            Assert.IsTrue(isRemoved, "RemoveAsync doesn't removed correct Object");
            mockRepo.Verify(x => x.GetAsync(1), Times.Once, "GetAsync should run once");
            mockRepo.Verify(x => x.RemoveAsync(getEntity),
                            Times.Once, "RemoveAsync should run once");
        }
Ejemplo n.º 2
0
        public async Task Setup()
        {
            await InitDatabaseInMemoryTest();

            categoryIncomeModelLists  = new List <Models.CategoryIncome>();
            categoryIncomeEntityLists = new List <Entities.CategoryIncome>();
            mockRepo   = new Mock <ICategoryIncomeRepository>();
            mockMapper = new Mock <IMapper>();
            categoryIncomeEntityObj = new Entities.CategoryIncome {
                Id = 2, Description = "CategoryIncome1", IsDeleted = false, Weight = 2, CategoryGroupId = 2
            };
            categoryIncomeModelObj = new Models.CategoryIncome {
                Id = 2, Description = "CategoryIncome2", IsDeleted = false, Weight = 2, CategoryGroupId = 2
            };
            categoryIncomeModelLists.Add(categoryIncomeModelObj);
        }
Ejemplo n.º 3
0
 public void Setup()
 {
     categoryIncomeObj = new Entities.CategoryIncome {
         Id = 2, Description = "CategoryIncome2", IsDeleted = false, Weight = 2, CategoryGroupId = 2
     };
     categoryIncomeModelObj = new Models.CategoryIncome {
         Id = 2, Description = "CategoryIncome2", IsDeleted = false, Weight = 2, CategoryGroupId = 2
     };
     mockCategoryIncomeRepository = new Mock <ICategoryIncomeRepository>();
     mockCategoryIncomeService    = new Mock <ICategoryIncomeService>();
     expectedIdOfCategoryIncome   = 2;
     categoryIncomeListObj        = new List <Models.CategoryIncome>()
     {
         new Models.CategoryIncome {
             Id = 2, Description = "CategoryIncome2", IsDeleted = false, Weight = 2, CategoryGroupId = 2
         }
     };
 }
Ejemplo n.º 4
0
        public async Task GetCategoryIncome_ShouldBeAbleToReturnOneObjectWithIdEquals8()
        {
            // Arrange
            categoryIncomeEntityObj = new Entities.CategoryIncome {
                Id = 8, Description = "description8"
            };

            mockRepo.Setup(y => y.GetAsync(It.IsAny <int>()))
            .Returns(Task.FromResult(categoryIncomeEntityObj));

            var sut = new CategoryIncomeService(mockRepo.Object, null);

            // Act
            var getAllEntities = await sut.GetAsync(8);

            // Assert
            Assert.AreEqual(8, getAllEntities.Id, "GetAsync doesn't return correct Object");
            mockRepo.Verify(x => x.GetAsync(8), Times.Once, "GetAsync should run once");
        }
Ejemplo n.º 5
0
 public async Task <bool> RemoveAsync(Entities.CategoryIncome categoryIncome)
 {
     return(await _categoryIncomeRepository.RemoveAsync(categoryIncome));
 }