Skip to content

Commit a6ce315

Browse files
committed
fix : Resolved comments
1 parent fff7d72 commit a6ce315

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockFileCopyTests.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,10 @@ public async Task MockFile_Copy_ShouldThrowIOExceptionWhenOverwritingWithSameNam
256256

257257
fileSystem.File.WriteAllText(path, "Hello");
258258

259-
await That(() => fileSystem.File.Copy(path, pathUpper, true)).Throws<IOException>().HasMessage($"The process cannot access the file '{pathUpper}' because it is being used by another process.");
259+
void Act() => fileSystem.File.Copy(path, pathUpper, true);
260+
261+
await That(Act).Throws<IOException>()
262+
.WithMessage($"The process cannot access the file '{pathUpper}' because it is being used by another process.");
260263
}
261264

262265
[Test]

tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockFileMoveTests.cs

+6-10
Original file line numberDiff line numberDiff line change
@@ -253,20 +253,16 @@ public async Task MockFile_Move_ShouldThrowNotSupportedExceptionWhenDestinationP
253253
[WindowsOnly(WindowsSpecifics.Drives)]
254254
public async Task MockFile_Move_CaseOnlyRename_ShouldChangeCase()
255255
{
256-
string sourceFilePath = @"c:\something\demo.txt";
257-
string destFilePath = @"c:\something\DEMO.TXT";
256+
var fileSystem = new MockFileSystem();
257+
string sourceFilePath = @"c:\temp\demo.txt";
258+
string destFilePath = @"c:\temp\DEMO.TXT";
258259
string sourceFileContent = "content";
259-
260-
var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
261-
{
262-
{
263-
sourceFilePath, new MockFileData(sourceFileContent)}
264-
});
260+
fileSystem.File.WriteAllText(sourceFilePath, sourceFileContent);
265261

266262
fileSystem.File.Move(sourceFilePath, destFilePath);
267263

268-
await That(fileSystem.FileExists(destFilePath)).IsTrue();
269-
await That(fileSystem.GetFile(destFilePath).TextContents).IsEqualTo(sourceFileContent);
264+
await That(fileSystem.File.Exists(destFilePath)).IsTrue();
265+
await That(fileSystem.File.ReadAllText(destFilePath)).IsEqualTo(sourceFileContent);
270266
}
271267

272268
[Test]

tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockFileTests.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -733,17 +733,17 @@ public async Task MockFile_OpenRead_ShouldReturnReadOnlyStream()
733733

734734
[Test]
735735
[WindowsOnly(WindowsSpecifics.Drives)]
736-
public async Task MockFile_Replace_SameSourceAndDestination_ShouldThrowIOException()
736+
public async Task MockFile_Replace_SourceAndDestinationDifferOnlyInCasing_ShouldThrowIOException()
737737
{
738-
string sourceFilePath = @"c:\something\demo.txt";
739-
string destFilePath = @"c:\something\Demo.txt";
738+
var fileSystem = new MockFileSystem();
739+
string sourceFilePath = @"c:\temp\demo.txt";
740+
string destFilePath = @"c:\temp\DEMO.txt";
740741
string fileContent = "content";
742+
fileSystem.File.WriteAllText(sourceFilePath, fileContent);
741743

742-
var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
743-
{
744-
{ sourceFilePath, new MockFileData(fileContent) }
745-
});
744+
void Act() => fileSystem.File.Replace(sourceFilePath, destFilePath, null, true);
746745

747-
await That(() => fileSystem.File.Replace(sourceFilePath, destFilePath, null, true)).Throws<IOException>().HasMessage("The process cannot access the file because it is being used by another process.");
746+
await That(Act).Throws<IOException>()
747+
.HasMessage("The process cannot access the file because it is being used by another process.");
748748
}
749749
}

0 commit comments

Comments
 (0)