Inheritance: DbContext
Ejemplo n.º 1
0
        // Use TestCleanup to run code after each test has run
        public void Dispose()
        {
#if EFCORE
            db.Database.EnsureDeleted();
#else
            db.Database.Delete();
#endif
            db.Dispose();
            db = null;
        }
Ejemplo n.º 2
0
        public DbAsyncTest()
        {
#if EFCORE
            var builder = new DbContextOptionsBuilder();
            builder.UseSqlite($"Filename=LinqKit.{Guid.NewGuid()}.db");

            db = new TestContext(builder.Options);
            db.Database.EnsureCreated();
#else
            db = new TestContext($"data source=(LocalDB)\\MSSQLLocalDB;attachdbfilename=|DataDirectory|\\LinqKit.{Guid.NewGuid()}.mdf;integrated security=True;connect timeout=30;MultipleActiveResultSets=True;App=EntityFramework");
#endif

            db.Entities.RemoveRange(db.Entities.ToList());
            db.Entities.AddRange(new[]
            {
                new Entity { Value = 123 },
                new Entity { Value = 67 },
                new Entity { Value = 3 }
            });
            db.SaveChanges();
        }