This is a migrated thread and some comments may be shown as answers.

IgnoreInstance, Properties, & Threadpooling

1 Answer 12 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
wtigotw
Top achievements
Rank 1
wtigotw asked on 10 Feb 2014, 07:26 PM
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

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 11 Feb 2014, 03:14 PM
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.
Tags
General Discussions
Asked by
wtigotw
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or