public void MockFile_Delete_ShouldRemoveFileFromFileSystem() { string fullPath = XFS.Path(@"c:\something\demo.txt"); var fileSystem = new MockFileSystem(new Dictionary <string, MockFileData> { { fullPath, new MockFileData("Demo text content") } }); var file = new MockFile(fileSystem); file.Delete(fullPath); Assert.That(fileSystem.FileExists(fullPath), Is.False); }
public void MockFile_Delete_ThrowsWhenFileIsReadOnly() { const string path = @"c:\something\read-only.txt"; var fileSystem = new MockFileSystem(new Dictionary <string, MockFileData> { { path, new MockFileData("Content") } }); var mockFile = new MockFile(fileSystem); mockFile.SetAttributes(path, FileAttributes.ReadOnly); var exception = Assert.Throws <UnauthorizedAccessException>(() => mockFile.Delete(path)); Assert.That(exception.Message, Is.EqualTo(string.Format("Access to the path '{0}' is denied.", path))); }
public void MockFile_Delete_ShouldRemoveFileFromFileSystem() { const string fullPath = @"c:\something\demo.txt"; var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData> { { fullPath, new MockFileData("Demo text content") } }); var file = new MockFile(fileSystem); file.Delete(fullPath); Assert.That(fileSystem.FileExists(fullPath), Is.False); }