Autofixture和Moq没有传递模拟参数

时间:2014-01-23 12:15:21

标签: unit-testing nunit moq asp.net-mvc-5 autofixture

我有一个参数传递到像这样的控制器

private EnglishForwardLotServiceBase<EnglishForwardLotData, AuctionData, LotFragmentData> englishForwardLotServiceBase;

public EnglishForwardController(
    EnglishForwardLotServiceBase<EnglishForwardLotData, AuctionData, LotFragmentData> englishForwardLotServiceBase)
{
   this.englishForwardLotServiceBase = englishForwardLotServiceBase;
}

EnglishForwardLotServiceBase的定义是

public class EnglishForwardLotServiceBase<LotData, AuctionData, LotFragmentData> : IEnglishForwardLotService<LotData> where AuctionData : PerfectChannel.Services.EnglishForwardLot.IEnglishForwardLotSetup

所以,在我的测试中,我试图像这样模仿englishForwardLotServiceBase

IFixture fixture = new Fixture().Customize(new AutoMoqCustomization());
Mock<IEnglishForwardLotService<EnglishForwardLotData>> englishForwardLotServiceBaseMock = fixture.Freeze<Mock<IEnglishForwardLotService<EnglishForwardLotData>>>();

问题是Autofiture / Moq没有使用模拟版本EnglishForwardLotServiceBase参数,而是实际实现。这使我的测试失败,你可以想象。

可能是什么问题?

0 个答案:

没有答案