public async Task GetOneTest(int id) { var connection = new SqliteConnection("DataSource=:memory:"); connection.Open(); var options = new DbContextOptionsBuilder <LetterDbContext>() .UseSqlite(connection) .Options; using (var context = new LetterDbContext(options)) { context.Database.EnsureCreated(); LetterDbContextInitializer.Initialize(context); } using (var context = new LetterDbContext(options)) { LettersQueries lettersQueries = GetLettersQueries(context); var result = await lettersQueries.GetOneAsync(id); if (result == null) { Assert.Null(result); } else { Assert.True(result.LetterID > 0); Assert.True(id.Equals(result.LetterID)); } } }
public async Task GetByConsumerTests() { var connection = new SqliteConnection("DataSource=:memory:"); connection.Open(); var options = new DbContextOptionsBuilder <LetterDbContext>() .UseSqlite(connection) .Options; using (var context = new LetterDbContext(options)) { context.Database.EnsureCreated(); LetterDbContextInitializer.Initialize(context); } using (var context = new LetterDbContext(options)) { LettersQueries lettersQueries = GetLettersQueries(context); var result = await lettersQueries.GetByTenantAsync(Guid.NewGuid()); if (result == null) { Assert.Null(result); } else { Assert.NotNull(result); Assert.True(result.Count > 0); } } }