private static Assembly LoadAssemblyInRuntime(LoadContextAssemblyResolver resolver) { // We need to load assembly that is not referenced by our project, thats why physical path is hardcoded var Module1WebModulePath = $"{AppContext.BaseDirectory}..\\..\\..\\Module1.Web\\bin\\netcoreapp2.1\\Module1.Web.dll"; var webRuntimeAssembly = resolver.LoadAssemblyFrom(Module1WebModulePath); return(webRuntimeAssembly); }
public void LoadAssemblyFrom_ThirdPartyAssemblyInDependentProject_IsLoadedCorrectly(bool isDevelopmentEnvironment) { // Arrange var loggerStub = Mock.Of <ILogger <LoadContextAssemblyResolver> >(); var resolver = new LoadContextAssemblyResolver(loggerStub, isDevelopmentEnvironment); // Act var webRuntimeAssembly = LoadAssemblyInRuntime(resolver); // To ensure assembly is loaded correctly with all recursive dependencies, need to instantiate controller and call the method that call third party dll functions var stringResult = CallControllerMethod(webRuntimeAssembly); // Assert Assert.NotNull(stringResult); }