public void Test()
        {
            using var connection = new SqliteConnection("Filename=:memory:");
            connection.Open();
            var builder = new DbContextOptionsBuilder <SuperheroContext>().UseSqlite(connection);

            using var context = new SuperheroContext(builder.Options);
            context.Database.EnsureCreated();
            context.GenerateTestData();

            Assert.Equal(2, context.Superheroes.Count());
        }
Esempio n. 2
0
        public SuperheroRepositoryTests()
        {
            _connection = new SqliteConnection("Filename=:memory:");
            _connection.Open();
            var builder = new DbContextOptionsBuilder <SuperheroContext>().UseSqlite(_connection);

            _context = new SuperheroContext(builder.Options);
            _context.Database.EnsureCreated();
            _context.GenerateTestData();

            _repository = new SuperheroRepository(_context);
        }