public async Task EditCategoryAsyncTest() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; var dbContext = new ApplicationDbContext(options); dbContext.Categories.Add( new Category { Id = 1, Name = "Test1", }); dbContext.Categories.Add( new Category { Id = 2, Name = "Test2", }); await dbContext.SaveChangesAsync(); var repository = new EfDeletableEntityRepository <Category>(dbContext); var service = new CategoriesService(repository); var category = service.FindCategoryById(2); category.Name = "Edited"; await service.EditCategoryAsync(category); var editedCategory = service.FindCategoryById(2); Assert.Equal(typeof(EditCategoryViewModel), category.GetType()); Assert.Equal(category.Name, editedCategory.Name); }