【发布时间】:2017-09-15 12:43:06
【问题描述】:
我一定会在我当前的项目中使用 Rhinomocks。有没有一种方法可以设置使用 Autofixture 和 Rhinomocks 来实现与使用 AutoConfiguredMoqCustomization 自定义将 AutoFixture 与 Moq 组合时相同的行为?
目前我必须在我的测试代码中进行很多虚拟模拟设置,如下所示。在代码中,我并不真正关心我创建的位置。我只希望 GetAllLocations 方法返回一个随机的位置列表而不是 null:
var f = new Fixture();
var masterDataProvider = MockRepository.GenerateStub<IMasterDataProvider>();
masterDataProvider.Stub(x => x.GetAllLocations()).Return(f.CreateMany<Location>());
f.Inject(masterDataProvider);
【问题讨论】: