Skip to content

Commit 3ee1da1

Browse files
committed
Make selector manifest tests platform-independent
Replace hardcoded "/tmp" paths with Path.GetTempPath() and build input paths dynamically. Update assertions to check the output filename and normalized directory path (using Path.GetFullPath and TrimEnd on DirectorySeparatorChar) so the tests work across platforms (e.g., Windows vs Unix) and with generated .g.cs suffixes.
1 parent a44ea69 commit 3ee1da1

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

tests/Motus.Cli.Tests/Services/SelectorManifestWriterTests.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,29 @@ public class SelectorManifestWriterTests
1010
[TestMethod]
1111
public void ManifestPathFor_ReplacesCsExtensionWithSelectorsJson()
1212
{
13-
var path = SelectorManifestWriter.ManifestPathFor(Path.Combine("/tmp", "LoginTest.cs"));
14-
Assert.AreEqual(Path.Combine("/tmp", "LoginTest.selectors.json"), path);
13+
var tempDir = Path.GetTempPath();
14+
var input = Path.Combine(tempDir, "LoginTest.cs");
15+
16+
var path = SelectorManifestWriter.ManifestPathFor(input);
17+
18+
Assert.AreEqual("LoginTest.selectors.json", Path.GetFileName(path));
19+
Assert.AreEqual(
20+
Path.GetFullPath(tempDir).TrimEnd(Path.DirectorySeparatorChar),
21+
Path.GetFullPath(Path.GetDirectoryName(path)!).TrimEnd(Path.DirectorySeparatorChar));
1522
}
1623

1724
[TestMethod]
1825
public void ManifestPathFor_StripsDotGSuffix()
1926
{
20-
var path = SelectorManifestWriter.ManifestPathFor(Path.Combine("/tmp", "LoginPage.g.cs"));
21-
Assert.AreEqual(Path.Combine("/tmp", "LoginPage.selectors.json"), path);
27+
var tempDir = Path.GetTempPath();
28+
var input = Path.Combine(tempDir, "LoginPage.g.cs");
29+
30+
var path = SelectorManifestWriter.ManifestPathFor(input);
31+
32+
Assert.AreEqual("LoginPage.selectors.json", Path.GetFileName(path));
33+
Assert.AreEqual(
34+
Path.GetFullPath(tempDir).TrimEnd(Path.DirectorySeparatorChar),
35+
Path.GetFullPath(Path.GetDirectoryName(path)!).TrimEnd(Path.DirectorySeparatorChar));
2236
}
2337

2438
[TestMethod]

0 commit comments

Comments
 (0)