Created
June 15, 2018 21:19
-
-
Save FraukeN/709cbae5e487e2fcbfd65de332bdda45 to your computer and use it in GitHub Desktop.
OverviewVM LoadData test with Moq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task LoadData_loads_data_from_repository() | |
{ | |
// Arrange | |
List<ToDoItem> toDoList = new List<ToDoItem>(); | |
for (int i = 0; i < 5; i++) | |
{ | |
toDoList.Add(new ToDoItem { Title = $"Item {i}" }); | |
} | |
Mock<IRepository<ToDoItem>> repoMock = new Mock<IRepository<ToDoItem>>(); | |
repoMock.Setup(repo => repo.GetAsync()).ReturnsAsync(toDoList); | |
OverviewVM vm = new OverviewVM(repoMock.Object); | |
// Act | |
await vm.LoadData(); | |
// Assert | |
Assert.That(vm.ToDoItems.Count(), Is.EqualTo(5)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment