Skip to content

MissingMethodException / "Method not found" after update to Moq 4.8.0 #566

@JHotterbeekxBannerconnect

Description

Hi,

Today I've tried updating the NuGet package from 4.7.145.0 to 4.8.0.0 and I'm running into an issue with a specific test case failing now on a strange error message. To give you some context, in our tests we create a HttpActionContext to test our authentication. This is native .net functionality. I've isolated the issue to the following code:

[Test]
public void OnActionExecuting_ShouldFillMarketInSession() {
  var fakeActionContext = _CreateFakeHttpActionContext();
}

private HttpActionContext _CreateFakeHttpActionContext() {
  return new HttpActionContext(null, new ReflectedHttpActionDescriptor()) {
    Response = new HttpResponseMessage(HttpStatusCode.OK)
  };
}

When running this test, it fails with the following error:

System.MissingMethodException : Method not found: 'Void System.Web.Http.Controllers.HttpActionContext.set_Response(System.Net.Http.HttpResponseMessage)'.
at SMP.Api.Test.Filter.MoqTest._CreateFakeHttpActionContext()
at SMP.Api.Test.Filter.MoqTest.OnActionExecuting_ShouldFillMarketInSession() in C:\Projects\Athena\Athena\SMP.Api.Test\Filter\MoqTest.cs:line 14

Could you help me figure out what is wrong, or fix this if it is an actual bug?

Thanks,
John

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions