public async Task CreateNewTodoItem_Should_Throw_ArgumentException_If_TodoItemText_Is_Empty(string todoItemText) { using (var context = _builder.BuildDbContext()) { var services = new TodoServices(context); var ex = await Assert.ThrowsAsync <ArgumentException>(() => services.CreateNewTodoItem(todoItemText)); Assert.Equal(nameof(todoItemText), ex.ParamName); } }
public async Task CreateNewTodoItem_Should_Add_A_Todo_Item_With_Specified_Text() { using (var context = _builder.BuildDbContext()) { var services = new TodoServices(context); string todoItemText = "My new todo"; await services.CreateNewTodoItem(todoItemText); Assert.Equal(todoItemText, context.TodoItems.FirstOrDefault()?.Text); _builder.CleanAllData(context); } }