Adding tests

This change required quite a few new tests. Before we could make new tests, though, we had to first rename our existing completion test to represent the correct functionality. Adding two more tests to the TodoListCompleteTests file, we verify both that the item is marked complete and that it is not removed from the TODO list:

public class TodoListCompleteTests
{
[Fact]
public void ItHidesAnItemFromTheList()
{
// Arrange
var todo = new TodoList();
var item = new Todo { Description = "Test Todo" };

todo.AddTodo(item);

// Act
todo.Complete(item);

// Assert
Assert.Equal(0, todo.Items.Count());
}

[Fact]
public void ItMarksAnItemComplete()
{
// Arrange
var todo = new TodoList();
var item = new Todo { Description = "Test Todo" };

todo.AddTodo(item);

// Act
todo.Complete(item);

// Assert
Assert.True(item.IsComplete);
}

[Fact]
public void ItShowsCompletedItems()
{
// Arrange
var todo = new TodoList();
var item = new Todo { Description = "Test Todo" };

todo.ShowCompleted = true;
todo.AddTodo(item);

// Act
todo.Complete(item);

// Assert
Assert.Equal(1, todo.Items.Count());
}
}

In order to add ShowComplete, we created a yak shaving test in the ToDoApplicationTests file for completeness:

[Fact(Skip = "Yak shaving - no longer needed")]
public void ShowCompletedExists()
{
// Arrange
var todo = new TodoList();

// Act
todo.ShowCompleted = true;
}

We also had to add a similar test to the TodoModelTests file:

[Fact]
public void ItHasIsComplete()
{
// Arrange
var todo = new Todo();

// Act
todo.IsComplete = true;
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.158.173