Skip to content

Commit 82e7751

Browse files
committed
fix duplicated project names, and improve error
1 parent 25d855c commit 82e7751

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

test/IntegrationTests/MSTest.Acceptance.IntegrationTests/ThreadingTests.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public async Task LifecycleAttributesTaskThreading_WhenMainIsNotSTA_RunsettingsA
188188
return;
189189
}
190190

191-
var testHost = TestHost.LocateFrom(AssetFixture.LifecycleAttributesTaskProjectPath, TestAssetFixture.LifecycleWithParallelAttributesTaskProjectName, tfm);
191+
var testHost = TestHost.LocateFrom(AssetFixture.LifecycleWithParallelAttributesTaskProjectNamePath, TestAssetFixture.LifecycleWithParallelAttributesTaskProjectName, tfm);
192192
string runSettingsFilePath = Path.Combine(testHost.DirectoryName, "sta.runsettings");
193193
TestHostResult testHostResult = await testHost.ExecuteAsync($"--settings {runSettingsFilePath}", environmentVariables: new()
194194
{
@@ -225,7 +225,7 @@ public sealed class TestAssetFixture() : TestAssetFixtureBase(AcceptanceFixture.
225225
public const string STAThreadProjectName = "STATestThreading";
226226
public const string LifecycleAttributesVoidProjectName = "LifecycleAttributesVoid";
227227
public const string LifecycleAttributesTaskProjectName = "LifecycleAttributesTask";
228-
public const string LifecycleWithParallelAttributesTaskProjectName = "LifecycleAttributesTask";
228+
public const string LifecycleWithParallelAttributesTaskProjectName = "LifecycleWithParallelAttributesTask";
229229
public const string LifecycleAttributesValueTaskProjectName = "LifecycleAttributesValueTask";
230230

231231
public string ProjectPath => GetAssetPath(ProjectName);
@@ -264,12 +264,14 @@ public sealed class TestAssetFixture() : TestAssetFixtureBase(AcceptanceFixture.
264264
yield return (LifecycleAttributesTaskProjectName, LifecycleAttributesTaskProjectName,
265265
LifecycleAttributesTaskSource
266266
.PatchTargetFrameworks(TargetFrameworks.All)
267+
.PatchCodeWithReplace("$ProjectName$", LifecycleAttributesTaskProjectName)
267268
.PatchCodeWithReplace("$ParallelAttribute$", string.Empty)
268269
.PatchCodeWithReplace("$MSTestVersion$", MSTestVersion));
269270

270271
yield return (LifecycleWithParallelAttributesTaskProjectName, LifecycleWithParallelAttributesTaskProjectName,
271272
LifecycleAttributesTaskSource
272273
.PatchTargetFrameworks(TargetFrameworks.All)
274+
.PatchCodeWithReplace("$ProjectName$", LifecycleWithParallelAttributesTaskProjectName)
273275
.PatchCodeWithReplace("$ParallelAttribute$", "[assembly: Parallelize(Workers = 0, Scope = ExecutionScope.MethodLevel)]")
274276
.PatchCodeWithReplace("$MSTestVersion$", MSTestVersion));
275277

@@ -529,7 +531,7 @@ private static void AssertCorrectThreadApartmentState()
529531
</RunConfiguration>
530532
</RunSettings>
531533
532-
#file LifecycleAttributesTask.csproj
534+
#file $ProjectName$.csproj
533535
<Project Sdk="Microsoft.NET.Sdk">
534536
535537
<PropertyGroup>

test/Utilities/Microsoft.Testing.TestInfrastructure/TestAsset.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ public TestAsset(string assetName, string assetCode, TempDirectory tempDirectory
1717
Name = assetName;
1818
_assetCode = assetCode;
1919
TargetAssetPath = Path.Combine(tempDirectory.Path, assetName);
20+
21+
if (Directory.Exists(TargetAssetPath))
22+
{
23+
throw new InvalidOperationException($"Directory / asset name '{assetName}' in '{tempDirectory.Path}' already exists. Make sure the paths for your test assets are unique. Typically you need to look into GetAssetsToGenerate method on the test fixture that is used for running the failing test");
24+
}
25+
2026
tempDirectory.CreateDirectory(assetName);
2127
}
2228

0 commit comments

Comments
 (0)