public void ShouldAddSeveralCategories()
        {
            var categories = new List <Category>()
            {
                new Category {
                    CategoryName = "Foo"
                },
                new Category {
                    CategoryName = "Bar"
                },
                new Category {
                    CategoryName = "FooBar"
                }
            };
            var count = _repo.AddRange(categories);

            Assert.Equal(3, count);
            Assert.Equal(3, _repo.GetAll().Count());
            Assert.Equal(3, _repo.Table.Count());
        }
        public void ShouldUpdateACategoryEntity()
        {
            var category = new Category {
                CategoryName = "Foo"
            };

            _repo.AddRange(new List <Category>
            {
                category,
            });
            category.CategoryName = "Bar";
            _repo.Update(category, false);
            var count = _repo.SaveChanges();

            Assert.Equal(1, count);
            using (var context = new StoreContextFactory().CreateDbContext(null))
            {
                using (var repo = new CategoryRepo(context))
                {
                    var cat = repo.Find(category.Id);
                    Assert.Equal(cat.CategoryName, category.CategoryName);
                }
            }
        }
Example #3
0
        public void ShouldDeleteACategoryEntityFromDbSet()
        {
            _repo.AddRange(new List <Category>
            {
                new Category {
                    CategoryName = "Foo"
                },
            });
            Assert.Equal(1, _repo.Table.Count());
            var category = _repo.GetAll().First();
            var count    = _repo.Delete(category);

            Assert.Equal(1, count);
            Assert.Equal(0, _repo.Table.Count());
        }