Unit Testing something that returns nothing, how to assert?
c#, unit-testing
Solution
You could assert that whatever happens after the `return` doesn't happen when `myProperty` is zero.
For example, if the method is (pseudo code!)
if myProperty == 0 return
myOtherProperty = 2
then your unit test could
- Arrange that `myProperty` is set to zero, `myOtherProperty` is set to something other than `2`
- Act by calling the method under test
- Assert that `myOtherProperty` is still set to what it was set to before.
Problem
How would you assert code like this? What would be the best approach to do so? ``` public void doSomething(int myProperty){ if (myProperty == 0) return; // If myProperty is not zero, do something in the method } ```