Arrange Conflicting with Assert

2 posts, 1 answers
  1. Kaya
    Kaya avatar
    3 posts
    Member since:
    Feb 2010

    Posted 26 Jul 2011 Link to this post

    If you are unit testing a method that gets an Arranged mocked property and, then, sets that property, how do you verify the results at then end?

    For example, let's say we want to unit test a method that looks like:

    public void MyMethod()
        if (_view.SelectedObject != null)
            _view.SelectedObject = null;

    I would expect to be able to write a test similar to:

    public void MyMethodTest()
        var view = Mock.Create<iView>();
        var testObject = new Thingy();
        Mock.Arrange(() => view.SelectedObject).Returns(testObject);
        Mock.ArrangeSet(() => view.SelectedObject = null);

    The assert fails because the mocked property return is still in effect and you get testObject.  What's the proper way to write this test?  Thanks!

  2. Answer
    Ricky avatar
    467 posts

    Posted 27 Jul 2011 Link to this post

    Hi Kaya,
    An answer is posted in Ticket ID: 447581. Please check it out.

    Kind Regards,
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. DevCraft R3 2016 release webinar banner
Back to Top