public MessageRepositoryTests(ITestOutputHelper testOutputHelper) { _testOutputHelper = testOutputHelper; _loggerUser = Mock.Of <ILogger <UserRepository> >(); _context = CreateMiniTwitContext(); _context.Database.EnsureDeleted(); _context.Database.EnsureCreated(); _userRepository = new UserRepository(_context, _loggerUser); _messageRepository = new MessageRepository(_context); }
public static MiniTwitTestContext CreateMiniTwitContext( [CallerMemberName] string testName = "", [CallerFilePath] string testNamePart2 = "" ) { var connection = new SqliteConnection("Datasource=:memory:"); connection.Open(); var options = new DbContextOptionsBuilder <MiniTwitContext>().UseSqlite(connection); var context = new MiniTwitTestContext(options.Options, connection); context.Database.EnsureCreated(); return(context); }