In your setup, you set the function to return null . You already indicated this in a comment, It.IsAny<Task>() returns null .
Setup(sf => sf.SynchronizeDataset(It.IsAny<string>())) .Returns(It.IsAny<Task>());
So if we break this:
_ServiceFacade.SynchronizeDataset(DATASET_NAME).ContinueWith(t => { if (t.IsFaulted) {
... equal
// This works, but returns null, so testing anything from this point is limited. var myNullTask = _ServiceFacade.SynchronizeDataset(DATASET_NAME); myNullTask.ContinueWith(t => ... ); // This yields NullReferenceException ((Task)null).ContinueWith(t => ... ); // Equivalent to line above
It looks like you are writing an integration test that does not apply to your code (if your actual code does not accept non-zero as return). If so, I suggest changing the setting to something like:
Setup(sf => sf.SynchronizeDataset(It.IsAny<string>())) .Returns(Task.CompletedTask);
source share