public async Task Can_Change_Todo_Item_State() { //Given var collection = new Collection { Name = "A Collection" }; var item = new TodoItem { Name = "An Item" }; collection.TodoItems.Add(item); await Database.OnceAndSaveAsync(async db => await db.Collections.AddAsync(collection)); await using var db = Database.Create(); var repository = new TodoItemRepository(db); // Then Assert.False(item.IsDone); //When var isSucceed = await repository.DoneAsync(item); //Then Assert.True(isSucceed); Assert.True(item.IsDone); // When var isSucceed2 = await repository.UndoneAsync(item); // Then Assert.True(isSucceed2); Assert.False(item.IsDone); }
public async Task <IActionResult> DoneAsync(int id) { var item = await _repository.FindAsync(id); await _repository.DoneAsync(item); return(new OkResult()); }