Skip to content

Commit c2b29b7

Browse files
committed
Fix failing test
1 parent 649b77f commit c2b29b7

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

Source/Testably.Abstractions.Testing/Helpers/Execute.SimulatedPath.cs

+17-11
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public string Combine(string path1, string path2)
4545
throw new ArgumentNullException(nameof(path2));
4646
}
4747

48-
return Combine([path1, path2]);
48+
return CombineInternal([path1, path2]);
4949
}
5050

5151
/// <inheritdoc cref="IPath.Combine(string, string, string)" />
@@ -66,7 +66,7 @@ public string Combine(string path1, string path2, string path3)
6666
throw new ArgumentNullException(nameof(path3));
6767
}
6868

69-
return Combine([path1, path2, path3]);
69+
return CombineInternal([path1, path2, path3]);
7070
}
7171

7272
/// <inheritdoc cref="IPath.Combine(string, string, string, string)" />
@@ -92,12 +92,12 @@ public string Combine(string path1, string path2, string path3, string path4)
9292
throw new ArgumentNullException(nameof(path4));
9393
}
9494

95-
return Combine([path1, path2, path3, path4]);
95+
return CombineInternal([path1, path2, path3, path4]);
9696
}
9797

9898
/// <inheritdoc cref="IPath.Combine(string[])" />
9999
public string Combine(params string[] paths)
100-
=> System.IO.Path.Combine(paths);
100+
=> CombineInternal(paths);
101101

102102
#if FEATURE_PATH_ADVANCED
103103
/// <inheritdoc cref="IPath.EndsInDirectorySeparator(ReadOnlySpan{char})" />
@@ -280,15 +280,15 @@ public bool IsPathRooted(ReadOnlySpan<char> path)
280280
#if FEATURE_PATH_JOIN
281281
/// <inheritdoc cref="IPath.Join(ReadOnlySpan{char}, ReadOnlySpan{char})" />
282282
public string Join(ReadOnlySpan<char> path1, ReadOnlySpan<char> path2)
283-
=> Join(path1.ToString(), path2.ToString());
283+
=> JoinInternal([path1.ToString(), path2.ToString()]);
284284
#endif
285285

286286
#if FEATURE_PATH_JOIN
287287
/// <inheritdoc cref="IPath.Join(ReadOnlySpan{char}, ReadOnlySpan{char}, ReadOnlySpan{char})" />
288288
public string Join(ReadOnlySpan<char> path1,
289289
ReadOnlySpan<char> path2,
290290
ReadOnlySpan<char> path3)
291-
=> Join(path1.ToString(), path2.ToString(), path3.ToString());
291+
=> JoinInternal([path1.ToString(), path2.ToString(), path3.ToString()]);
292292
#endif
293293

294294
#if FEATURE_PATH_ADVANCED
@@ -297,7 +297,7 @@ public string Join(ReadOnlySpan<char> path1,
297297
ReadOnlySpan<char> path2,
298298
ReadOnlySpan<char> path3,
299299
ReadOnlySpan<char> path4)
300-
=> Join(path1.ToString(), path2.ToString(), path3.ToString(), path4.ToString());
300+
=> JoinInternal([path1.ToString(), path2.ToString(), path3.ToString(), path4.ToString()]);
301301
#endif
302302

303303
#if FEATURE_PATH_ADVANCED
@@ -314,7 +314,7 @@ public string Join(string? path1, string? path2)
314314
return path1;
315315
}
316316

317-
return Join([path1, path2]);
317+
return JoinInternal([path1, path2]);
318318
}
319319
#endif
320320

@@ -337,7 +337,7 @@ public string Join(string? path1, string? path2, string? path3)
337337
return Join(path1, path2);
338338
}
339339

340-
return Join([path1, path2, path3]);
340+
return JoinInternal([path1, path2, path3]);
341341
}
342342
#endif
343343

@@ -365,14 +365,14 @@ public string Join(string? path1, string? path2, string? path3, string? path4)
365365
return Join(path1, path2, path3);
366366
}
367367

368-
return Join([path1, path2, path3, path4]);
368+
return JoinInternal([path1, path2, path3, path4]);
369369
}
370370
#endif
371371

372372
#if FEATURE_PATH_ADVANCED
373373
/// <inheritdoc cref="IPath.Join(string[])" />
374374
public string Join(params string?[] paths)
375-
=> System.IO.Path.Join(paths);
375+
=> JoinInternal(paths);
376376
#endif
377377

378378
#if FEATURE_PATH_ADVANCED
@@ -407,5 +407,11 @@ public bool TryJoin(ReadOnlySpan<char> path1,
407407
#endif
408408

409409
#endregion
410+
411+
private static string CombineInternal(string[] paths)
412+
=> System.IO.Path.Combine(paths);
413+
414+
private static string JoinInternal(string?[] paths)
415+
=> System.IO.Path.Join(paths);
410416
}
411417
}

Tests/Testably.Abstractions.Testing.Tests/Helpers/PathHelperTests.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public void ThrowCommonExceptionsIfPathIsInvalid_WithInvalidCharacters(
129129
{
130130
MockFileSystem fileSystem = new(i => i
131131
.SimulatingOperatingSystem(SimulationMode.Windows));
132-
string path = fileSystem.Path.GetFullPath(invalidChar + "path");
132+
string path = invalidChar + "path";
133133

134134
Exception? exception = Record.Exception(() =>
135135
{
@@ -138,10 +138,10 @@ public void ThrowCommonExceptionsIfPathIsInvalid_WithInvalidCharacters(
138138

139139
#if NETFRAMEWORK
140140
exception.Should().BeOfType<ArgumentException>()
141-
.Which.Message.Should().Contain($"'{path}'");
141+
.Which.Message.Should().Contain(path);
142142
#else
143143
exception.Should().BeOfType<IOException>()
144-
.Which.Message.Should().Contain($"'{path}'");
144+
.Which.Message.Should().Contain(path);
145145
#endif
146146
}
147147

0 commit comments

Comments
 (0)