public async void TestFindByAsync() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "SchemaDatabase") .Options; var dbContext = new ApplicationDbContext(options); var repo = new SchemaRepository(dbContext); // Act var result = await repo.FindByAsync(x => x.Id > 0); // Assert Assert.True(result is IEnumerable <Schema>); }
public async void TestDeleteAsync() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "SchemaDatabase") .Options; var dbContext = new ApplicationDbContext(options); var repo = new SchemaRepository(dbContext); // Act var newSchema = await repo.CreateAsync(new Schema { SavedDate = DateTime.Now, SchemaJson = "{id: 123}" }); var createdId = newSchema.Id; await repo.DeleteAsync(createdId); var searchResult = await repo.FindByAsync(x => x.Id == createdId); if (searchResult.Count() == 0) { } // Assert Assert.True(createdId > 0 && searchResult.Count() == 0); }