コード例 #1
0
        protected DbContextTestSetup()
        {
            DbContextOptionsBuilder <BmtDbContext> builder = new DbContextOptionsBuilder <BmtDbContext>();
            string connectionString = new SqliteConnectionStringBuilder {
                DataSource = "file::memory:", Cache = SqliteCacheMode.Shared
            }.ToString();

            _connection = new SqliteConnection(connectionString);
            _connection.Open();
            builder.EnableSensitiveDataLogging();
            builder.UseSqlite(_connection);
            _context = new BmtDbContext(builder.Options);
            _context.Database.EnsureCreated();
            InitContent.PopulateDb(_context);
        }
コード例 #2
0
ファイル: Startup.cs プロジェクト: nicholasdalhaug/fusion-bmt
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;

            // In-memory sqlite requires an open connection throughout the whole lifetime of the database
            _sqlConnectionString = Configuration.GetSection("Database").GetValue <string>("ConnectionString");
            if (string.IsNullOrEmpty(_sqlConnectionString))
            {
                DbContextOptionsBuilder <BmtDbContext> builder = new DbContextOptionsBuilder <BmtDbContext>();
                string connectionString = new SqliteConnectionStringBuilder {
                    DataSource = "file::memory:", Cache = SqliteCacheMode.Shared
                }.ToString();
                _connection = new SqliteConnection(connectionString);
                _connection.Open();
                builder.UseSqlite(_connection);

                using (BmtDbContext context = new BmtDbContext(builder.Options))
                {
                    context.Database.EnsureCreated();
                    InitContent.PopulateDb(context);
                }
            }
        }
コード例 #3
0
ファイル: WeiMinTest.cs プロジェクト: WeiMin-M/Waffles
        public void TestSearchStageName()
        {
            List <string> al = new List <string>();

            al.Add("Stage Name 1");
            al.Add("Stage Name 2");
            al.Add("Stage Name 3");
            al.Add("Hello");
            al.Add("Bye");
            InitContent ic = new InitContent();

            int count = 0;

            foreach (string temp in al)
            {
                if (ic.Search(temp, "Stage"))
                {
                    count++;
                }
            }

            Assert.AreEqual(3, count);
        }