public async Task RemoveItemAsync_SQLiteException() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase("MovieListDatabase") .Options; var scope = CreateNewScopeSqliteException(); var context = scope.CreateScope().ServiceProvider .GetService <ApplicationDbContext>(); if (context == null) { throw new NullReferenceException( "test context should not be null"); } await context.FileIndex.AddAsync(new FileIndexItem("/test.jpg")); await context.SaveChangesAsync(); var item = await context.FileIndex.FirstOrDefaultAsync( p => p.FilePath == "/test.jpg"); var sqLiteFailContext = new SqliteExceptionDbContext(options); Assert.AreEqual(0, sqLiteFailContext.Count); var fakeQuery = new Query(sqLiteFailContext, null, scope, new FakeIWebLogger()); await fakeQuery.RemoveItemAsync(item); Assert.AreEqual(1, sqLiteFailContext.Count); }
public async Task AddItemAsync_SQLiteException() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase("MovieListDatabase") .Options; var scope = CreateNewScopeSqliteException(); var sqLiteFailContext = new SqliteExceptionDbContext(options); Assert.AreEqual(0, sqLiteFailContext.Count); var fakeQuery = new Query(sqLiteFailContext, null, scope, new FakeIWebLogger()); await fakeQuery.AddItemAsync(new FileIndexItem("/test22.jpg")); Assert.AreEqual(1, sqLiteFailContext.Count); }