Skip to content

Instantly share code, notes, and snippets.

@FraukeN
Last active June 15, 2018 22:49
Show Gist options
  • Save FraukeN/4b8e93a49c75401a89eef3ee5158368c to your computer and use it in GitHub Desktop.
Save FraukeN/4b8e93a49c75401a89eef3ee5158368c to your computer and use it in GitHub Desktop.
OverviewVMTests with test for repo exception
[Test]
public async Task LoadData_sets_IsFaulted_to_true_if_LoadData_encounters_an_exception()
{
// Arrange
Mock<IRepository<ToDoItem>> repoMock = new Mock<IRepository<ToDoItem>>();
repoMock.Setup(repo => repo.GetAsync()).ThrowsAsync(new Exception());
OverviewVM vm = new OverviewVM(repoMock.Object);
// Act
await vm.LoadData();
// Assert
Assert.That(vm.IsFaulted, Is.True);
Assert.That(vm.ErrorMessage, Is.EqualTo("Unable to Load ToDo Items"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment