The situation is that I have a test class that needs a CollectionFixture
injected, this latter needs another one to be injected to it also. This is not working.
This is my collection definition
[CollectionDefinition(nameof(AssemblyFixtures ))]
public class AssemblyFixtures :
ICollectionFixture<DataMock>,
ICollectionFixture<ItemCatalogSearchApiFactory>
{
}
And I have a test class :
[Collection(nameof(AssemblyFixtures))]
public class TestBase
{
private readonly ItemCatalogSearchApiFactory _apiFactory;
private readonly ITestOutputHelper _outputHelper;
public TestBase(ItemCatalogSearchApiFactory apiFactory, ITestOutputHelper outputHelper)
{
_apiFactory = apiFactory;
_outputHelper = outputHelper;
}
}
and ItemCatalogSearchApiFactory
that needs DataMock
[Collection(nameof(AssemblyFixtures))]
public class ItemCatalogSearchApiFactory : WebApplicationFactory<Startup>
{
public ItemCatalogSearchApiFactory(DataMock dataMock)
{
//using DataMock for some reason here
}
}
This doesn't work and it fails to instantiate ItemCatalogSearchApiFactory
with the following error thrown :
Message: System.AggregateException : One or more errors occurred. (Collection fixture type 'XXXXXXX.IntegrationTests.ItemCatalogSearchApiFactory' had one or more unresolved constructor arguments: DataMock dataMock) (The following constructor parameters did not have matching fixture data: ItemCatalogSearchApiFactory apiFactory) ---- Collection fixture type 'XXXXXXX.IntegrationTests.ItemCatalogSearchApiFactory' had one or more unresolved constructor arguments: DataMock dataMock ---- The following constructor parameters did not have matching fixture data: ItemCatalogSearchApiFactory apiFactory Stack Trace: ----- Inner Stack Trace #1 (Xunit.Sdk.TestClassException) ----- ----- Inner Stack Trace #2 (Xunit.Sdk.TestClassException) -----
Is this the normal behavior ? Any Idea how should correct this situation ?