Skip to content
Merged
30 changes: 25 additions & 5 deletions TestHelpers.Tests/MockFileCopyTests.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
namespace System.IO.Abstractions.TestingHelpers.Tests
{
using Collections.Generic;

using Globalization;

using Linq;

using NUnit.Framework;

using XFS = MockUnixSupport;

public class MockFileCopyTests {
public class MockFileCopyTests
{

[Test]
public void MockFile_Copy_ShouldOverwriteFileWhenOverwriteFlagIsTrue()
{
Expand Down Expand Up @@ -271,5 +269,27 @@ public void MockFile_Copy_ShouldThrowArgumentExceptionWhenTargetIsEmpty_Message(

Assert.That(exception.Message, Does.StartWith("Empty file name is not legal."));
}

[Test]
public void MockFile_Copy_ShouldThrowExceptionWhenSourceDoesNotExist()
{
string sourceFilePath = XFS.Path(@"c:\something\demo.txt");
var fileSystem = new MockFileSystem();

TestDelegate action = () => fileSystem.File.Copy(sourceFilePath, XFS.Path(@"c:\something\demo2.txt"));

Assert.Throws<FileNotFoundException>(action);
}

[Test]
public void MockFile_Copy_ShouldThrowExceptionWhenSourceDoesNotExist_EvenWhenCopyingToItself()
{
string sourceFilePath = XFS.Path(@"c:\something\demo.txt");
var fileSystem = new MockFileSystem();

TestDelegate action = () => fileSystem.File.Copy(sourceFilePath, XFS.Path(@"c:\something\demo.txt"));

Assert.Throws<FileNotFoundException>(action);
}
}
}
Loading