diff --git a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileStreamFactoryStatisticsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileStreamFactoryStatisticsTests.cs index edd1fa65..13671e0e 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileStreamFactoryStatisticsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileStreamFactoryStatisticsTests.cs @@ -189,21 +189,29 @@ public void Method_New_String_FileStreamOptions_ShouldRegisterCall() [SkippableFact] public void Method_Wrap_FileStream_ShouldRegisterCall() { + string path = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); MockFileSystem sut = new(); - FileStream fileStream = new("foo", FileMode.OpenOrCreate); - try { - using FileSystemStream result = sut.FileStream.Wrap(fileStream); + using FileStream fileStream = new(path, FileMode.OpenOrCreate); + + try + { + using FileSystemStream result = sut.FileStream.Wrap(fileStream); + } + catch (NotSupportedException) + { + // Wrap is not possible on the MockFileSystem, but should still be registered! + } + + sut.StatisticsRegistration.TotalCount.Should().Be(1); + sut.Statistics.FileStream.ShouldOnlyContainMethodCall(nameof(IFileStreamFactory.Wrap), + fileStream); } - catch (NotSupportedException) + finally { - // Wrap is not possible on the MockFileSystem, but should still be registered! + File.Delete(path); } - - sut.StatisticsRegistration.TotalCount.Should().Be(1); - sut.Statistics.FileStream.ShouldOnlyContainMethodCall(nameof(IFileStreamFactory.Wrap), - fileStream); } [SkippableFact]