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);
        }
Example #2
0
        public void MockFileInfo_Encrypt_ShouldSetEncryptedAttributeOfFileInMemoryFileSystem()
        {
            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();

            Assert.AreEqual(FileAttributes.Encrypted, fileData.Attributes & FileAttributes.Encrypted);
        }
        public void MockFileInfo_Encrypt_ShouldReturnXorOfFileInMemoryFileSystem()
        {
            // Arrange
            MockFileData   fileData   = new MockFileData("Demo text content");
            MockFileSystem fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { XFS.Path(@"c:\a.txt"), fileData }
            });
            MockFileInfo fileInfo = new MockFileInfo(fileSystem, XFS.Path(@"c:\a.txt"));

            // Act
            fileInfo.Encrypt();

            string newcontents;

            using (StreamReader newfile = fileInfo.OpenText())
            {
                newcontents = newfile.ReadToEnd();
            }

            // Assert
            Assert.NotEqual("Demo text content", newcontents);
        }
        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);
        }