I have an application which has depends on 2 custom build nugets. Lets call hem DepA (version 1.6.0) and DepB (version 1.2.5) for now. Both DepA and DepB depend on DepP but on different versions:
- DepA wants version: 1.5.0 of DepP
- DepB wants version : 1.7.1 of DepP
The difference between 1.5.0 and 1.7.1 is that 1.7.1 has a new interface, which 1.5.0 doesn’t have. When I start the application, it throws an error on startup on code of DepA:
System.IO.FileNotFoundException: ‘Could not load file or
assembly ‘DepP, Version=1.5.0.0, Culture=neutral,
PublicKeyToken=null’. The system cannot find the file specified.’
The error makes sense, since dependecy tree decided to load 1.7.1 DepP and ofcourse DepA is not satisfied with that. So upgrading DepA to use also 1.7.1 will resolve the issue.
But to detect this issue in the pipeline I have created an integration test project which will use the Mvc Testing library. I have defined the following test:
await using var factory = new WebApplicationFactory<Program>();
var client = factory.CreateClient();
var response = await client.GetAsync("/");
response.IsSuccessStatusCode.Should().BeTrue();
This test will execute the same code as if I would startup the application it hits the same lines (debugged the test) but no exception is thrown. It runs just fine. How is this possible?