【发布时间】:2016-01-29 14:03:46
【问题描述】:
我正在使用AutoFixture as an auto-mocking container 并想模拟HttpResponse,以便我可以验证是否已设置特定的StatusCode。但是,当我打电话给SetupSet 时,我得到了NotImplementedException:
var response = _fixture.Freeze<Mock<HttpResponseBase>>();
response
.SetupSet(x => x.StatusCode = It.IsAny<int>());
如果我只使用 HttpResponseBase 的新 Mock,我也不例外,但是我必须编写一个 FreezeMoq 扩展方法,如 Mark Seemann 的 Freezing mocks 博客文章中所述。
AutoFixture 的作用是什么,这意味着我无法在基类抛出 NotImplementedException 的虚拟属性上设置集合,但仅使用 Moq 时可以?
【问题讨论】:
标签: c# unit-testing autofixture