diff --git a/Source/Testably.Abstractions.Testing/Helpers/Execute.LinuxPath.cs b/Source/Testably.Abstractions.Testing/Helpers/Execute.LinuxPath.cs
index 43b5868b..ae8eb9c2 100644
--- a/Source/Testably.Abstractions.Testing/Helpers/Execute.LinuxPath.cs
+++ b/Source/Testably.Abstractions.Testing/Helpers/Execute.LinuxPath.cs
@@ -104,11 +104,13 @@ protected override bool IsDirectorySeparator(char c)
protected override bool IsEffectivelyEmpty(string path)
=> string.IsNullOrEmpty(path);
+#if FEATURE_PATH_RELATIVE
///
/// https://github.com/dotnet/runtime/blob/v8.0.4/src/libraries/Common/src/System/IO/PathInternal.Unix.cs#L77
///
protected override bool IsPartiallyQualified(string path)
=> !IsPathRooted(path);
+#endif
///
/// https://github.com/dotnet/runtime/blob/v8.0.4/src/libraries/Common/src/System/IO/PathInternal.Unix.cs#L39
diff --git a/Source/Testably.Abstractions.Testing/Helpers/Execute.SimulatedPath.cs b/Source/Testably.Abstractions.Testing/Helpers/Execute.SimulatedPath.cs
index 1d51d114..0a23b059 100644
--- a/Source/Testably.Abstractions.Testing/Helpers/Execute.SimulatedPath.cs
+++ b/Source/Testably.Abstractions.Testing/Helpers/Execute.SimulatedPath.cs
@@ -550,6 +550,7 @@ string NormalizePath(string path)
return sb.ToString();
}
+#if FEATURE_PATH_RELATIVE
///
/// We have the same root, we need to calculate the difference now using the
/// common Length and Segment count past the length.
@@ -606,7 +607,9 @@ private string CreateRelativePath(string relativeTo, string path, int commonLeng
return sb.ToString();
}
+#endif
+#if FEATURE_PATH_RELATIVE
///
/// Get the common path length from the start of the string.
///
@@ -653,12 +656,15 @@ private int GetCommonPathLength(string first, string second,
return commonChars;
}
+#endif
protected abstract int GetRootLength(string path);
protected abstract bool IsDirectorySeparator(char c);
protected abstract bool IsEffectivelyEmpty(string path);
+#if FEATURE_PATH_RELATIVE
protected abstract bool IsPartiallyQualified(string path);
+#endif
#if FEATURE_PATH_JOIN || FEATURE_PATH_ADVANCED
private string JoinInternal(string?[] paths)
diff --git a/Source/Testably.Abstractions.Testing/Helpers/Execute.WindowsPath.cs b/Source/Testably.Abstractions.Testing/Helpers/Execute.WindowsPath.cs
index 78c5a4d4..03bcd6ba 100644
--- a/Source/Testably.Abstractions.Testing/Helpers/Execute.WindowsPath.cs
+++ b/Source/Testably.Abstractions.Testing/Helpers/Execute.WindowsPath.cs
@@ -251,6 +251,7 @@ protected override bool IsEffectivelyEmpty(string path)
return path.All(c => c == ' ');
}
+#if FEATURE_PATH_RELATIVE
///
/// https://github.com/dotnet/runtime/blob/v8.0.4/src/libraries/Common/src/System/IO/PathInternal.Windows.cs#L250
///
@@ -279,6 +280,7 @@ protected override bool IsPartiallyQualified(string path)
// not qualified if you don't have a valid drive. "=:\" is the "=" file's default data stream.
&& IsValidDriveChar(path[0]));
}
+#endif
///
/// Returns true if the given character is a valid drive letter
diff --git a/Tests/Testably.Abstractions.Testing.Tests/NotificationTests.cs b/Tests/Testably.Abstractions.Testing.Tests/NotificationTests.cs
index da6ee7d7..9d6d1cac 100644
--- a/Tests/Testably.Abstractions.Testing.Tests/NotificationTests.cs
+++ b/Tests/Testably.Abstractions.Testing.Tests/NotificationTests.cs
@@ -19,13 +19,13 @@ public void AwaitableCallback_Amount_ShouldOnlyReturnAfterNumberOfCallbacks()
}
});
- _ = Task.Run(() =>
+ _ = Task.Run(async () =>
{
- Thread.Sleep(10);
+ await Task.Delay(10);
for (int i = 1; i <= 10; i++)
{
timeSystem.Thread.Sleep(i);
- Thread.Sleep(1);
+ await Task.Delay(1);
}
});
@@ -82,13 +82,13 @@ public void AwaitableCallback_Filter_ShouldOnlyUpdateAfterFilteredValue()
receivedCount++;
});
- _ = Task.Run(() =>
+ _ = Task.Run(async () =>
{
- Thread.Sleep(10);
+ await Task.Delay(10);
for (int i = 1; i <= 10; i++)
{
timeSystem.Thread.Sleep(i);
- Thread.Sleep(1);
+ await Task.Delay(1);
}
});
@@ -107,16 +107,16 @@ public void AwaitableCallback_Predicate_ShouldOnlyUpdateAfterFilteredValue()
receivedCount++;
}, t => t.TotalMilliseconds > 6);
- _ = Task.Run(() =>
+ _ = Task.Run(async () =>
{
// ReSharper disable once AccessToDisposedClosure
try
{
- Thread.Sleep(10);
+ await Task.Delay(10);
for (int i = 1; i <= 10; i++)
{
timeSystem.Thread.Sleep(i);
- Thread.Sleep(1);
+ await Task.Delay(1);
}
ms.Set();
@@ -145,7 +145,7 @@ public void AwaitableCallback_ShouldWaitForCallbackExecution()
isCalled = true;
});
- _ = Task.Run(() =>
+ _ = Task.Run(async () =>
{
// ReSharper disable once AccessToDisposedClosure
try
@@ -153,7 +153,7 @@ public void AwaitableCallback_ShouldWaitForCallbackExecution()
while (!ms.IsSet)
{
timeSystem.Thread.Sleep(1);
- Thread.Sleep(1);
+ await Task.Delay(1);
}
}
catch (ObjectDisposedException)
diff --git a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileSystemWatcherStatisticsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileSystemWatcherStatisticsTests.cs
index 4d3b0136..618f5f39 100644
--- a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileSystemWatcherStatisticsTests.cs
+++ b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileSystemWatcherStatisticsTests.cs
@@ -4,6 +4,7 @@
using System.Threading.Tasks;
using Testably.Abstractions.Testing.Statistics;
using Testably.Abstractions.Testing.Tests.TestHelpers;
+// ReSharper disable MethodSupportsCancellation
namespace Testably.Abstractions.Testing.Tests.Statistics.FileSystem;
@@ -46,11 +47,11 @@ public void Method_WaitForChanged_WatcherChangeTypes_Int_ShouldRegisterCall()
// Changes in the background are necessary, so that FileSystemWatcher.WaitForChanged returns.
using CancellationTokenSource cts = new(TimeSpan.FromSeconds(30));
CancellationToken token = cts.Token;
- _ = Task.Run(() =>
+ _ = Task.Run(async () =>
{
while (!token.IsCancellationRequested)
{
- Thread.Sleep(10);
+ await Task.Delay(10);
sut.Directory.CreateDirectory(sut.Path.Combine("foo", "some-directory"));
sut.Directory.Delete(sut.Path.Combine("foo", "some-directory"));
}
@@ -76,11 +77,11 @@ public void Method_WaitForChanged_WatcherChangeTypes_ShouldRegisterCall()
// Changes in the background are necessary, so that FileSystemWatcher.WaitForChanged returns.
using CancellationTokenSource cts = new();
CancellationToken token = cts.Token;
- _ = Task.Run(() =>
+ _ = Task.Run(async () =>
{
while (!token.IsCancellationRequested)
{
- Thread.Sleep(10);
+ await Task.Delay(10);
sut.Directory.CreateDirectory(sut.Path.Combine("foo", "some-directory"));
sut.Directory.Delete(sut.Path.Combine("foo", "some-directory"));
}
@@ -105,11 +106,11 @@ public void Method_WaitForChanged_WatcherChangeTypes_TimeSpan_ShouldRegisterCall
// Changes in the background are necessary, so that FileSystemWatcher.WaitForChanged returns.
using CancellationTokenSource cts = new(TimeSpan.FromSeconds(30));
CancellationToken token = cts.Token;
- _ = Task.Run(() =>
+ _ = Task.Run(async () =>
{
while (!token.IsCancellationRequested)
{
- Thread.Sleep(10);
+ await Task.Delay(10);
sut.Directory.CreateDirectory(sut.Path.Combine("foo", "some-directory"));
sut.Directory.Delete(sut.Path.Combine("foo", "some-directory"));
}
diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/EventTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/EventTests.cs
index 86c2c41d..8315052b 100644
--- a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/EventTests.cs
+++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/EventTests.cs
@@ -2,6 +2,8 @@
using System.IO;
using System.Threading;
using System.Threading.Tasks;
+// ReSharper disable MethodSupportsCancellation
+// ReSharper disable MethodHasAsyncOverloadWithCancellation
namespace Testably.Abstractions.Tests.FileSystem.FileSystemWatcher;
@@ -41,7 +43,7 @@ void FileSystemWatcherOnChanged(object sender, FileSystemEventArgs e)
try
{
- _ = Task.Run(() =>
+ _ = Task.Run(async () =>
{
// ReSharper disable once AccessToDisposedClosure
try
@@ -51,7 +53,7 @@ void FileSystemWatcherOnChanged(object sender, FileSystemEventArgs e)
{
string content = i++.ToString(CultureInfo.InvariantCulture);
FileSystem.File.WriteAllText(path, content);
- Thread.Sleep(10);
+ await Task.Delay(10);
ms1.Set();
}
}
@@ -114,7 +116,7 @@ void FileSystemWatcherOnCreated(object sender, FileSystemEventArgs e)
try
{
- _ = Task.Run(() =>
+ _ = Task.Run(async () =>
{
// ReSharper disable once AccessToDisposedClosure
try
@@ -123,7 +125,7 @@ void FileSystemWatcherOnCreated(object sender, FileSystemEventArgs e)
{
FileSystem.Directory.CreateDirectory(path);
FileSystem.Directory.Delete(path);
- Thread.Sleep(10);
+ await Task.Delay(10);
ms1.Set();
}
}
@@ -184,7 +186,7 @@ void FileSystemWatcherOnDeleted(object sender, FileSystemEventArgs e)
try
{
- _ = Task.Run(() =>
+ _ = Task.Run(async () =>
{
// ReSharper disable once AccessToDisposedClosure
try
@@ -193,7 +195,7 @@ void FileSystemWatcherOnDeleted(object sender, FileSystemEventArgs e)
{
FileSystem.Directory.CreateDirectory(path);
FileSystem.Directory.Delete(path);
- Thread.Sleep(10);
+ await Task.Delay(10);
ms1.Set();
}
}
@@ -255,7 +257,7 @@ void FileSystemWatcherOnRenamed(object sender, FileSystemEventArgs e)
try
{
- _ = Task.Run(() =>
+ _ = Task.Run(async () =>
{
// ReSharper disable once AccessToDisposedClosure
try
@@ -265,7 +267,7 @@ void FileSystemWatcherOnRenamed(object sender, FileSystemEventArgs e)
while (!token.IsCancellationRequested)
{
FileSystem.File.Move($"path-{i}", $"path-{++i}");
- Thread.Sleep(10);
+ await Task.Delay(10);
ms1.Set();
}
}
diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/Tests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/Tests.cs
index 1f7dbc56..ec36cdca 100644
--- a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/Tests.cs
+++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/Tests.cs
@@ -28,14 +28,14 @@ public void BeginInit_ShouldStopListening(string path)
fileSystemWatcher.EnableRaisingEvents.Should().BeTrue();
try
{
- _ = Task.Run(() =>
+ _ = Task.Run(async () =>
{
// ReSharper disable once AccessToDisposedClosure
try
{
while (!ms.IsSet)
{
- Thread.Sleep(10);
+ await Task.Delay(10);
FileSystem.Directory.CreateDirectory(path);
FileSystem.Directory.Delete(path);
}
@@ -86,14 +86,14 @@ public void EndInit_ShouldRestartListening(string path)
fileSystemWatcher.EnableRaisingEvents.Should().BeTrue();
try
{
- _ = Task.Run(() =>
+ _ = Task.Run(async () =>
{
// ReSharper disable once AccessToDisposedClosure
try
{
while (!ms.IsSet)
{
- Thread.Sleep(10);
+ await Task.Delay(10);
FileSystem.Directory.CreateDirectory(path);
FileSystem.Directory.Delete(path);
}
diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/WaitForChangedTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/WaitForChangedTests.cs
index 947f4ce0..6fd74459 100644
--- a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/WaitForChangedTests.cs
+++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/WaitForChangedTests.cs
@@ -19,14 +19,14 @@ public void WaitForChanged_ShouldBlockUntilEventHappens(string path)
FileSystem.FileSystemWatcher.New(BasePath);
try
{
- _ = Task.Run(() =>
+ _ = Task.Run(async () =>
{
// ReSharper disable once AccessToDisposedClosure
try
{
while (!ms.IsSet)
{
- Thread.Sleep(10);
+ await Task.Delay(10);
FileSystem.Directory.CreateDirectory(path);
FileSystem.Directory.Delete(path);
}
@@ -68,14 +68,14 @@ public void WaitForChanged_Timeout_ShouldReturnTimedOut(string path,
try
{
fileSystemWatcher.EnableRaisingEvents = true;
- _ = Task.Run(() =>
+ _ = Task.Run(async () =>
{
// ReSharper disable once AccessToDisposedClosure
try
{
while (!ms.IsSet)
{
- Thread.Sleep(10);
+ await Task.Delay(10);
FileSystem.Directory.CreateDirectory(fullPath);
FileSystem.Directory.Delete(fullPath);
}