vendredi 29 janvier 2016

Mocking HttpResponse.StatusCode with AutoFixture and Moq

I am using AutoFixture as an auto-mocking container and want to mock an HttpResponse so that I can verify that a specific StatusCode has been set. However, I am getting a NotImplementedException when I call SetupSet:

var response = _fixture.Freeze<Mock<HttpResponseBase>>();
response
    .SetupSet(x => x.StatusCode = It.IsAny<int>());

If I just use a new Mock of HttpResponseBase, I get no exception, but then I would have to write a FreezeMoq extension method as explained in Mark Seemann's Freezing mocks blog post.

What is AutoFixture doing that means I cannot setup a set on virtual property where the base class throws a NotImplementedException, but can when just using Moq?

Aucun commentaire:

Enregistrer un commentaire