IgnoreInstance, Properties, & Threadpooling

2 posts, 0 answers
  1. wtigotw
    wtigotw avatar
    1 posts
    Member since:
    Apr 2010

    Posted 10 Feb 2014 Link to this post

    Hello,

    I'm attempting to use the following code to arrange that all TcpClients return true for having a valid connection:
                TcpClient localClient = Mock.Create<TcpClient>(Constructor.Mocked, Behavior.Strict);
                Mock.Arrange(() => localClient.Connected).IgnoreInstance().Returns(true);
    This code seems to work fine when I'm on the same thread, but if the access to Connected occurs on a different thread, this does not seem to function correctly.

    My best guess is it has something to do with the use of either IgnoreInstance in conjunction with a property instead of a method (something I can't seem to find examples of so I wonder if it's supported or not), the fact that Threadpool mocking is not supported on the trial version, something I'm doing wrong, or a bug.

    I've also attempted to mock the containing class such that it will always return a mocked instance of the TcpClient for any instance and that does not seem to function correctly on a thread either:
                Mock.NonPublic.Arrange<TcpClient>(typeof(CustomConnectionHandler), "TcpConnection").IgnoreInstance().Returns(localClient);
    On the thread I always seem to get a different instance of the TcpClient - not localClient

    Any thoughts,

    Thanks
  2. Stefan
    Admin
    Stefan avatar
    198 posts

    Posted 11 Feb 2014 Link to this post

    Hello Wes,

    I'm closing this ticket as it seems to be a duplicate of your other ticket.

    Regards,
    Stefan
    Telerik
    Share what you think about JustTrace & JustMock with us, so we can become even better! You can use the built-in feedback tool inside JustTrace, our forums, or our JustTrace or JustMock portals.
  3. DevCraft R3 2016 release webinar banner
Back to Top