-
-
Notifications
You must be signed in to change notification settings - Fork 801
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
Weird exception when mocking interface with SignalRHubAttribute applied #1308
Comments
Thanks for the error report, this will likely boil down to a problem in the DynamicProxy library. I'll investigate shortly and, if Moq indeed isn't the culprit, forward a modified report to their repository. |
@kimbirkelund, I cannot reproduce any test failures. I had to change the following lines of code in order to get a runnable test: - var exception = setup.Invoking(s => s.Returns(new Mock<IThrow>().Object))
- .Should().Throw<NullReferenceException>()
- .Which;
+ var exception = Assert.Throws<NullReferenceException>(() => s.Returns(new Mock<IThrow>().Object)); Could you please re-post minimally complete repro code (ideally with no package references other than to Xunit and Moq) that has at least one failing test? |
Interesting. I've attached a project that shows the issue when running And just to avoid any misunderstanding: all tests pass if the issue is repro'ed. The test with the assertion demonstrates the problem by catching the exception that shouldn't be thrown. I apologize if that wasn't clear by me original post. I've further attached the result of running Let me know if you need anything further. |
Ah, I see. That's a somewhat unusual way to go about it :-) but in that case I can repro it. Will take another look! |
Sorry that wasn't clear. I thought it was the most precise way to show where the exception was thrown and what kind it was. |
No big deal. I'm usually expecting a test failure to signal where something goes wrong. Also, your test name Never mind though, I know what I need to look at now. :-) |
Yeah, that wasn't really thought through :-) |
@kimbirkelund, this is indeed a bug in DynamicProxy. I've forwarded your bug report with simplified test cases, see castleproject/Core#637. |
@kimbirkelund, I've just released Moq version 4.18.4, which contains a bugfix that should resolve your issue. |
Good to hear. Looking forward to get it. Thanks for your hard work 👍 |
Hi
First of all thanks for a nice framework 👍
I've run into a weird problem. The following tests shows the problem, with the first test exposing the problem:
The only case the exception occurs is if the
AttributeUsageAttribute.Inherited
property is explicitly set tofalse
(even though that is the default value) and the attribute has an array parameter that isnull
.This is the exception (using LINQPad):
I'm using Moq version 4.18.3 and .NET 7. Also in use is Xunit and FluentAssertions.
The text was updated successfully, but these errors were encountered: