Esempio n. 1
0
        public void ExtractInterfaceEncoded()
        { // Type 1
            EngineState s      = EngineTests.CreateEngineState();
            string      scPath = Path.Combine("%TestBench%", "EncodedFile", "ExtractFileTests.script");

            scPath = StringEscaper.Preprocess(s, scPath);
            Script sc = s.Project.LoadScriptRuntime(scPath, new LoadScriptRuntimeOptions());

            byte[] extractDigest;
            using (MemoryStream ms = EncodedFile.ExtractInterface(sc, "PEBakeryAlphaMemory.jpg"))
            {
                extractDigest = HashHelper.GetHash(HashHelper.HashType.SHA256, ms);
            }

            string originFile = Path.Combine("%TestBench%", "EncodedFile", "PEBakeryAlphaMemory.jpg");

            originFile = StringEscaper.Preprocess(s, originFile);
            byte[] originDigest;
            using (FileStream fs = new FileStream(originFile, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                originDigest = HashHelper.GetHash(HashHelper.HashType.SHA256, fs);
            }

            // Compare Hash
            Assert.IsTrue(originDigest.SequenceEqual(extractDigest));
        }