我最近升级到了.NET 6.0版本,但在我的OData单元测试项目中遇到了以前从未遇到的错误。当运行以下单元测试时,我遇到了一个[System.ArgumentNullException: Value cannot be null. (Parameter 'type')]的错误:
[Fact]
public void Startup_Configure_Ok()
{
// Arrange
ServiceCollection serviceCollection = new ServiceCollection();
serviceCollection.AddOData();
ServiceProvider provider = serviceCollection.BuildServiceProvider();
var appBuilder = new ApplicationBuilder(provider);
var routeBuilder = new RouteBuilder(appBuilder);
routeBuilder.EnableDependencyInjection();
Startup startup = new Startup(_fixture.GetConfiguration());
// Act
startup.Configure(appBuilder);
// Assert
Assert.True(true);
}
有什么建议吗?
堆栈跟踪:
Message:
System.ArgumentNullException : Value cannot be null. (Parameter 'type')
Stack Trace:
IntrospectionExtensions.GetTypeInfo(Type type)
DefaultContainerBuilder.BuildContainer()
PerRouteContainerBase.CreateODataRootContainer(Action`1 configureAction)
PerRouteContainerBase.CreateODataRootContainer(String routeName, Action`1 configureAction)
ODataRouteBuilderExtensions.EnableDependencyInjection(IRouteBuilder builder, Action`1 configureAction)
ODataRouteBuilderExtensions.EnableDependencyInjection(IRouteBuilder builder)
StartupUnitTest.Startup_Configure_Ok() line 43