public static void DeleteAll <T>(TestContextMemory ctx, Func <TestContextMemory, DbSet <T> > func) where T : class
        {
            var sets = func(ctx);

            sets.RemoveRange(sets);
            ctx.SaveChanges();

            Assert.AreEqual(0, sets.Count());
        }
Esempio n. 2
0
        public static List <T> Insert <T>(TestContextMemory ctx, Func <TestContextMemory, DbSet <T> > func, int count) where T : class, new()
        {
            var sets = func(ctx);

            var countBefore = sets.Count();

            var list = new List <T>();

            for (var i = 0; i < count; i++)
            {
                var item = new T();
                InsertFactory(item, i);
                list.Add(item);
            }

            sets.AddRange(list);
            ctx.SaveChanges();

            Assert.AreEqual(count + countBefore, sets.Count());

            return(list);
        }