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 Link to this post

    In a method like

    void ReturnIfObjectIsNull()
            {
                var obj = new SomeObject();
     
                if (obj == null)
                    return;
     
                // 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.

    Thanks.

  2. Svetlozar
    Admin
    Svetlozar avatar
    269 posts

    Posted 19 Oct Link to this post

    Hi,

    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. 

    Regards,
    Svetlozar
    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
  3. DevCraft R3 2016 release webinar banner
Back to Top