Exemplo n.º 1
0
        public void TestSerializeAndEncryptVolume()
        {
            Volume volume = new Volume();

            volume.AddFile(CreateFile("test1.txt", 100));
            volume.AddFile(CreateFile("test2.txt", 100));
            volume.AddFile(CreateFile("test3.txt", 100));

            MemoryStream memoryStream = new MemoryStream();

            volume.Serialize(memoryStream, "password", 1);

            memoryStream.Seek(0, SeekOrigin.Begin); //start at beginning of stream
            var deserializedVolume = Volume.Deserialize(memoryStream, "password", int.MaxValue);

            Assert.IsNotNull(deserializedVolume);
            Assert.IsTrue(deserializedVolume.Folder.Files.Count == volume.Folder.Files.Count);
            for (int i = 0; i < volume.Folder.Files.Count; i++)
            {
                Assert.IsTrue(volume.Folder.Files[i].Data.SequenceEqual(deserializedVolume.Folder.Files[i].Data));
            }
        }