From ccf428bc4217d072c5b1a05f33d5afa07fb66455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1sp=C3=A1r=20Nagy?= Date: Thu, 7 Nov 2024 12:26:32 +0100 Subject: [PATCH] fix test execution with NCrunch --- .../RuntimePluginLocatorTests.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Tests/Reqnroll.PluginTests/RuntimePluginLocatorTests.cs b/Tests/Reqnroll.PluginTests/RuntimePluginLocatorTests.cs index c1dca8a27..707c347db 100644 --- a/Tests/Reqnroll.PluginTests/RuntimePluginLocatorTests.cs +++ b/Tests/Reqnroll.PluginTests/RuntimePluginLocatorTests.cs @@ -75,7 +75,7 @@ private List GetProjectReferencesDlls() foreach (string projectReference in projectReferences) { //real ref, not test dependent - if (projectReference.Contains("Reqnroll.Generator.csproj")) + if (!projectReference.Contains("ReqnrollPlugin")) continue; var index = projectReference.LastIndexOf("\\", StringComparison.InvariantCulture); @@ -96,10 +96,17 @@ private List GetProjectReferences() .Elements("ItemGroup") .Elements("ProjectReference") .Attributes("Include") - .Select(i => i.Value) - .ToList(); + .Select(i => i.Value); - return projectReferences; + // For running this test with NCrunch we need to load the assembly references as well + // because NCrunch replaces project references with assembly references in the project file. + var assemblyReferences = project.Element("Project") + .Elements("ItemGroup") + .Elements("Reference") + .Attributes("Include") + .Select(i => Path.GetFileNameWithoutExtension(i.Value) + ".csproj"); + + return projectReferences.Concat(assemblyReferences).ToList(); } }