Looking at MyClass.TryDoSomething()
code I think there are 2 cases which should be tested:
DoSomething
is null: Then you just need to check there is noNullReferenceException
whenTryDoSomething()
is called. No need to verify whetherDoSomething
Action is called as there is nothing to call.DoSomething
is not null: Then you need to check thatDoSomething
is called whenTryDoSomething()
is called. Your own answer shows a good example how to do this. But of cource you need to ChangeAssert.IsFalse()
toAssert.IsTrue()
.