Asserting that return was called after condition met in void type method

2 posts, 0 answers
  1. Gerard
    Gerard avatar
    4 posts
    Member since:
    Apr 2016

    Posted 14 Oct 2016 Link to this post

    In a method like

    void ReturnIfObjectIsNull()
                var obj = new SomeObject();
                if (obj == null)
                // Do other stuff..


    How do I assert that the early return fired (without asserting that the stuff that would have happened afterword never occurred).
    Asserting the object is null is not enough. I would need to assert that he function returned early when the object was null.


  2. Svetlozar
    Svetlozar avatar
    296 posts

    Posted 19 Oct 2016 Link to this post


    Thank you for your feedback!

    I am sorry If I am missing something, but it is not really clear what you want to achieve. Currently I don't see how you can assert that a method has returned at an arbitrary place. I guess you could add empty DoNothing method before the return you are interested in and assert that it has been called. 

    Telerik by Progress
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top