Пример #1
0
        public void ShouldDeleteACategoryRangeFromDbSet()
        {
            var categories = new List <Category>
            {
                new Category {
                    CategoryName = "Foo"
                },
                new Category {
                    CategoryName = "Bar"
                },
                new Category {
                    CategoryName = "FooBar"
                }
            };

            _repo.AddRange(categories);
            Assert.Equal(3, _repo.Table.Count());
            var count = _repo.DeleteRange(categories);

            Assert.Equal(3, count);
            Assert.Equal(0, _repo.Table.Count());
        }
Пример #2
0
        public void ShouldDeleteACategoryRangeAndPersistManuallyFromDbSet()
        {
            var categories = new List <Category>
            {
                new Category {
                    CategoryName = "Foo"
                },
                new Category {
                    CategoryName = "Bar"
                },
                new Category {
                    CategoryName = "FooBar"
                }
            };

            _repo.AddRange(categories);
            Assert.Equal(3, _repo.Table.Count());
            var count = _repo.DeleteRange(categories, false);

            Assert.Equal(0, count);
            count = _repo.SaveChanges();
            Assert.Equal(3, count);
            Assert.Equal(0, _repo.Table.Count());
        }