【发布时间】:2021-10-27 21:15:13
【问题描述】:
我真的迷失在集成测试单元主题中,在我的微服务中,我有一个从 azure bus 获取数据的类,它有一个将数据存储在数据库中的方法,我需要为它编写一个集成测试,什么到目前为止我已经完成了:
public class FxRateRepositoryTest
{
public IFxRateRepository fxraterepo;
public FxRateRepositoryTest(IFxRateRepository fxraterepo) => this.fxraterepo = fxraterepo;
[Fact]
public void StoreFxRatesAsync_True()
{
var newrate = new List<Rate> {
new Rate
{
CurrencyPair="HHGHGH",
MidRate=1,
RateTimestampInUtc=DateTime.UtcNow.ToString()
}
};
var newFx = new FXRefreshResponseDTO()
{
Rates = newrate
};
var rslt = this.fxraterepo.StoreFxRatesAsync(newFx);
Assert.True(rslt.Result);
}
}
我得到一个错误xunit构造函数参数异常没有匹配的夹具数据,我搜索了一下错误,结果我需要添加类似的东西:
public class FxRateRepositoryTest : IClassFixture<CustomWebApplicationFactory<Startup>>
说实话,我不知道是什么,但我仍然遇到同样的错误,知道吗?非常感谢您的帮助
【问题讨论】:
标签: c# asp.net-core integration-testing