Ejemplo n.º 1
0
        public void AddRange_InsertAtLeastOneNewCategory_ReturnsIds()
        {
            mockCategoryRepo.Setup(repo => repo.SelectAllAsync())
            .ReturnsAsync(selectedList);

            var categoryService = new CategoryService(mockCategoryRepo.Object, mapper);
            var result          = categoryService.AddRange(names);

            Assert.That(result.Result, Is.InstanceOf <IEnumerable <string> >());
        }
Ejemplo n.º 2
0
        public void AddRange_InsertTwoNewCategories_AddRangeAsyncMethodOfRepoIsCalledOnce()
        {
            mockCategoryRepo.Setup(repo => repo.SelectAllAsync())
            .ReturnsAsync(selectedList);

            var categoryService = new CategoryService(mockCategoryRepo.Object, mapper);

            categoryService.AddRange(names);

            mockCategoryRepo.Verify(m => m.AddRangeAsync(It.IsAny <IEnumerable <CategoryDB> >()), Times.Once);
        }
Ejemplo n.º 3
0
        public void AddRange_InsertAllExistingCategories_ReturnsNullAndAddRangeAsyncMethodOfRepoIsNeverCalled()
        {
            selectedList.Add(categoryDB);
            mockCategoryRepo.Setup(repo => repo.SelectAllAsync())
            .ReturnsAsync(selectedList);

            var categoryService = new CategoryService(mockCategoryRepo.Object, mapper);
            var result          = categoryService.AddRange(names);

            Assert.That(result, Is.Null);
            mockCategoryRepo.Verify(m => m.AddRangeAsync(It.IsAny <IEnumerable <CategoryDB> >()), Times.Never);
        }
Ejemplo n.º 4
0
        public void TestAddition()
        {
            GenericUnitOfWork uow  = new GenericUnitOfWork();
            CategoryService   ctgr = new CategoryService(uow);

            ctgr.AddRange(new List <Category>()
            {
                new POCO.Category {
                    CategoryName = "Liquid Milk"
                },
                new POCO.Category {
                    CategoryName = "Yourgut"
                },
                new POCO.Category {
                    CategoryName = "Powdered milk"
                },
                new POCO.Category {
                    CategoryName = "Infant Cereals"
                },
                new POCO.Category {
                    CategoryName = "Condensed Milk"
                },
                new POCO.Category {
                    CategoryName = "Special Nutrition Products for Adults"
                },
                new POCO.Category {
                    CategoryName = "Beverages"
                },
                new POCO.Category {
                    CategoryName = "Ice Cream"
                },
                new POCO.Category {
                    CategoryName = "Cheese"
                },
                new POCO.Category {
                    CategoryName = "Soymilk"
                }
            })
            ;
        }