-
-
Notifications
You must be signed in to change notification settings - Fork 798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems with Task in 4.2 version #78
Comments
@alextercete or @Blewzman: do you have an idea of what the issue might be? |
@mmajcica, are |
@alextercete This is the signature of both of the methods. SortCriteria GetSortCriteriaFromCache(string cacheKey); Seems that issue is due to the fact that moq in this version treats the threads in a different way. Test didin't changed and if I revert the mock to 4.0 it is green. |
This evening I will try to replicate with a small example and come back with more details. |
@danielkzu, I think the issue here is not related to the recent async improvements in Moq. It might be related to #68 though. |
@MatKubicki you think this might be related? |
I've tried what I assume is a set of tests similiar to the code mmajcica has and it fails in the way reported. And when I add the lock in the Interceptor that was removed for #68 it passes. So this seems to be a problem with handling the setups when they are run in multiple threads. I will see if I will have a look at sorting this out, although this is my last day working. For reference this test seems to replicate the issue:
|
Thanks for taking the time to look at this issue @MatKubicki ! |
On the above PR, I had a few go's at fixing this problem. The root of it is that the CurrentCall property on the InterceptorStrategyContext was being set on multiple threads and then used later on, what I needed to add was a CurrentCall property for each thread working through Interceptor.Intercept. In the PR I've done this by splitting the InterceptorStrategyContext into a class used by all intercepts (InterceptorContext) and a class used by each thread in Intercept (CurrentInterceptContext). The only thing on CurrentInterceptContext is the CurrentCall, I did try removing that entirely from the context as it can easily be pulled from the ordered calls list, I made the code in ExtractProxyCall to do this shared and this worked for all but one case. This case was the MockSequence tests where getting the CurrentCall more than once resulted in incorrect behaviour and MockSequenceFixture.NoCyclicSequenceFail and CyclicSequenceSuccesss failing. The problem was checking the status of a Condition changes the sequence number, so checking more than once changes behaviour, there is a note in the original code indicating this slightly hacky nature! See MockSequence.For for this comment, I didn't have time to start tearing apart this code as well as the interceptor, so have gone with the easier fix described. If someone who knows their way around wants to take a shot over Christmas then go for it! Hope this rambling was of use, |
@danielkzu When will this be available via NuGet? Thanks |
since I updated to the latest version of Moq (4.2) I'm having some unit test failing. I'm getting the System.InvalidCastException: Unable to cast object of type 'FilterCriteria' to type 'SortCriteria'. As my code uses Task's to get these values I suspect the new version of Moq works differently than previous one.
This is the code in question:
In tested class:
In unit test:
Any idea on what it can be due to? I really do not know where to start.
Thanks
The text was updated successfully, but these errors were encountered: