public void MockFileInfo_Decrypt_ShouldReturnCorrectContentsFileInMemoryFileSystem() { // Arrange var fileData = new MockFileData("Demo text content"); var fileSystem = new MockFileSystem(new Dictionary <string, MockFileData> { { XFS.Path(@"c:\a.txt"), fileData } }); var fileInfo = new MockFileInfo(fileSystem, XFS.Path(@"c:\a.txt")); fileInfo.Encrypt(); // Act fileInfo.Decrypt(); string newcontents; using (var newfile = fileInfo.OpenText()) { newcontents = newfile.ReadToEnd(); } // Assert Assert.AreEqual("Demo text content", newcontents); }
public void MockFileInfo_Decrypt_ShouldUnsetEncryptedAttributeOfFileInMemoryFileSystem() { var fileData = new MockFileData("Demo text content"); var fileSystem = new MockFileSystem(new Dictionary <string, MockFileData> { { XFS.Path(@"c:\a.txt"), fileData } }); var fileInfo = new MockFileInfo(fileSystem, XFS.Path(@"c:\a.txt")); fileInfo.Encrypt(); fileInfo.Decrypt(); Assert.AreNotEqual(FileAttributes.Encrypted, fileData.Attributes & FileAttributes.Encrypted); }
public void MockFileInfo_Decrypt_ShouldReturnCorrectContentsFileInMemoryFileSystem() { // Arrange var fileData = new MockFileData("Demo text content"); var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData> { { XFS.Path(@"c:\a.txt"), fileData } }); var fileInfo = new MockFileInfo(fileSystem, XFS.Path(@"c:\a.txt")); fileInfo.Encrypt(); // Act fileInfo.Decrypt(); string newcontents; using (var newfile = fileInfo.OpenText()) { newcontents = newfile.ReadToEnd(); } // Assert Assert.AreEqual("Demo text content", newcontents); }