Can't arrange method call on different object of same type after invocation.

3 posts, 0 answers
  1. Erik
    Erik avatar
    13 posts
    Member since:
    May 2011

    Posted 30 Apr 2012 Link to this post

    I have an odd case where I have multiple tests running on the same class. For most of these tests I am mocking a method on the class to return controlled results. One of the tests actually uses the normal version of the method. When the test that uses the concrete version of the method call runs first then I am unable to mock the method in the other tests.

    Here is some example code depicting my issue:
    var first = new MyClass();
    var second = new MyClass();
    Mock.Arrange(() => first.DoSomething()).Returns(new List<IDataItem>);

    In the code above, first will actually call the method rather than using the mock. Is this a bug? It seems like a bug. Is there a work around?
  2. Ricky
    Ricky avatar
    467 posts

    Posted 02 May 2012 Link to this post

    Hi Erik,

    Its great that you’ve got what you are looking for. However, should you have any other questions please don’t hesitate to contact us.

    Kind Regards
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top