예제 #1
0
        public DbContextFixture()
        {
            var optionsBuilder = new DbContextOptionsBuilder <TestsDbContext>();

            optionsBuilder.UseInMemoryDatabase("Force");
            DbContext = new TestsDbContext(optionsBuilder.Options);
        }
예제 #2
0
        static DbContextFixture()
        {
            var optionsBuilder = new DbContextOptionsBuilder <TestsDbContext>();

            optionsBuilder.UseInMemoryDatabase("Force");
            var dbContext = new TestsDbContext(optionsBuilder.Options);

            var category = new Category(FirstCategoryName);

            dbContext.Products.Add(new Product(category, FirstProductName)
            {
                Id = 1,
            });

            dbContext.Products.Add(new Product(category, SecondProductName)
            {
                Id = 2,
            });

            dbContext.Products.Add(new Product(category, "P3")
            {
                Id = 3,
            });

            dbContext.Products.Add(new Product(category, LastProductName)
            {
                Id = 10,
            });
//
//            dbContext.Products.Add(new Product()
//            {
//                Id = 2,
//                Name = "123"
//            });
//
//            dbContext.Products.Add(new Product()
//            {
//                Id = 3,
//                Name = "Abc"
//            });

            dbContext.SaveChanges();
        }