Skip to content

Commit 156192b

Browse files
committed
Fixed the unit test cases
1 parent d532971 commit 156192b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{}
2+

Contentstack.Core.Unit.Tests/Mokes/Utilities.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ public static class Utilities
1414
{
1515
public static string GetResourceText(string resourceName)
1616
{
17-
using (StreamReader reader = new StreamReader(GetResourceStream(resourceName)))
17+
var stream = GetResourceStream(resourceName);
18+
if (stream == null)
19+
{
20+
throw new FileNotFoundException($"Resource stream for '{resourceName}' is null");
21+
}
22+
using (StreamReader reader = new StreamReader(stream))
1823
{
1924
return reader.ReadToEnd();
2025
}
@@ -34,6 +39,13 @@ public static Stream GetResourceStream(string resourceName)
3439
{
3540
return new FileStream(filePath, FileMode.Open, FileAccess.Read);
3641
}
42+
// Try alternative path (for test execution)
43+
var altPath = Path.Combine(baseDirectory, "Mokes", "Response", resourceName);
44+
if (File.Exists(altPath))
45+
{
46+
return new FileStream(altPath, FileMode.Open, FileAccess.Read);
47+
}
48+
throw new FileNotFoundException($"Resource '{resourceName}' not found. Searched for: {resource}");
3749
}
3850
return stream;
3951
}

0 commit comments

Comments
 (0)