Beispiel #1
0
        public void ReadFileInfo()
        {
            // ReSharper disable once InconsistentNaming
            const string FolderExample = "FolderExample";
            const string folderExample = "folderExample";

            EngineState s = EngineTests.CreateEngineState();
            string      pbOriginScript = Path.Combine("%TestBench%", "EncodedFile", "ExtractFileTests.script");
            string      originScript   = StringEscaper.Preprocess(s, pbOriginScript);
            Script      sc             = s.Project.LoadScriptRuntime(originScript, new LoadScriptRuntimeOptions());

            // ReSharper disable once ParameterOnlyUsedForPreconditionCheck.Local
            void Template(string fileName, bool detail, EncodedFileInfo comp)
            {
                ResultReport <EncodedFileInfo> report = EncodedFile.ReadFileInfo(sc, folderExample, fileName, detail);

                Assert.IsTrue(report.Success);
                Assert.IsTrue(comp.Equals(report.Result));
            }

            Template("Type1.jpg", true, new EncodedFileInfo
            {
                FolderName  = FolderExample,
                FileName    = "Type1.jpg",
                RawSize     = 7683,
                EncodedSize = 10244,
                EncodeMode  = EncodedFile.EncodeMode.ZLib
            });
            Template("type1.jpg", false, new EncodedFileInfo
            {
                FolderName  = folderExample,
                FileName    = "Type1.jpg",
                RawSize     = 7683,
                EncodedSize = 10244,
                EncodeMode  = null
            });

            Template("Type2.7z", true, new EncodedFileInfo
            {
                FolderName  = FolderExample,
                FileName    = "Type2.7z",
                RawSize     = 1631,
                EncodedSize = 2175,
                EncodeMode  = EncodedFile.EncodeMode.Raw
            });
            Template("Type2.7z", false, new EncodedFileInfo
            {
                FolderName  = FolderExample,
                FileName    = "type2.7z",
                RawSize     = 1631,
                EncodedSize = 2175,
                EncodeMode  = null
            });

            Template("Type3.pdf", true, new EncodedFileInfo
            {
                FolderName  = FolderExample,
                FileName    = "Type3.pdf",
                RawSize     = 88692,
                EncodedSize = 102908,
                EncodeMode  = EncodedFile.EncodeMode.XZ
            });
            Template("Type3.pdf", false, new EncodedFileInfo
            {
                FolderName  = folderExample,
                FileName    = "type3.pdf",
                RawSize     = 88692,
                EncodedSize = 102908,
                EncodeMode  = null
            });
        }