コード例 #1
0
        public void TestMicrosoftAesStrategyFactory()
        {
            var options = new FileSystemOptions("", StreamEncryptionType.MicrosoftAes, StreamCompressionType.None);
            var encryptionOptions = GetEncryptionOptions();
            options.EncryptionKey = encryptionOptions.Key;
            options.EncryptionInitializationVector = encryptionOptions.InitializationVector;
            var res = new StramStrategyResolver(options);
            var s = res.ResolveStrategy();

            using (var ms = new MemoryStream())
            {
                var a = s.DecorateToVFS(ms);
                var b = s.DecorateToHost(ms);
                Assert.AreNotSame(ms, a);
                Assert.AreNotSame(ms, b);
                Assert.IsTrue(a is CryptoStream);
                Assert.IsTrue(b is CryptoStream);
                var c = a as CryptoStream;
                var d = b as CryptoStream;
                Assert.AreEqual(false, c.CanRead);
                Assert.AreEqual(true, c.CanWrite);
                Assert.AreEqual(true, d.CanRead);
                Assert.AreEqual(false, d.CanWrite);
            }
        }
コード例 #2
0
        public void TestCompressionLz77StrategyFail3()
        {
            var res = new StramStrategyResolver(new FileSystemOptions("", StreamEncryptionType.None, StreamCompressionType.SelfMadeLz77));
            var s = res.ResolveStrategy();

            using (var ms = new MemoryStream())
            {
                var a = s.DecorateToVFS(ms) as SelfMadeLz77Stream;
                Assert.IsNotNull(a);
                var x = a.Length;
            }
        }
コード例 #3
0
        public void TestCompressionLz77Strategy()
        {
            var res = new StramStrategyResolver(new FileSystemOptions("", StreamEncryptionType.None, StreamCompressionType.SelfMadeLz77));
            var s = res.ResolveStrategy();

            using (var ms = new MemoryStream())
            {
                var a = s.DecorateToVFS(ms);
                var b = s.DecorateToHost(ms);
                Assert.AreNotSame(ms, a);
                Assert.AreNotSame(ms, b);
                Assert.IsTrue(a is SelfMadeLz77Stream);
                Assert.IsTrue(b is SelfMadeLz77Stream);
                var c = a as SelfMadeLz77Stream;
                var d = b as SelfMadeLz77Stream;
                Assert.AreEqual(false, c.CanRead);
                Assert.AreEqual(true, c.CanWrite);
                Assert.AreEqual(true, d.CanRead);
                Assert.AreEqual(false, d.CanWrite);

                Assert.IsFalse(c.CanSeek);
            }
        }
コード例 #4
0
        public void TestCompressionLz77StrategyFail6()
        {
            var res = new StramStrategyResolver(new FileSystemOptions("", StreamEncryptionType.None, StreamCompressionType.SelfMadeLz77));
            var s = res.ResolveStrategy();

            using (var ms = new MemoryStream())
            {
                var a = s.DecorateToVFS(ms) as SelfMadeLz77Stream;
                Assert.AreEqual(0, a.Read(new byte[10], -1, 0));
            }
        }