Exemple #1
0
        public void TestReadSiiFile()
        {
            SiiFileReader reader = new SiiFileReader();
            Object        fromBinary, fromText;

            using (MemoryStream s = new MemoryStream(Resources.Samples.GameEncrypted)) {
                fromBinary = reader.ReadSiiFile(s).Result;
            }

            using (Stream s = new MemoryStream(Resources.Samples.GameText)) {
                fromText = reader.ReadSiiFile(s).Result;
            }

            Assert.AreEqual(fromBinary.Children.Count, fromText.Children.Count);
        }
        public void TestInclusion()
        {
            GameFs gameFs = new GameFs(ExternalPaths.GameInstallPath, null);

            Task.WaitAll(gameFs.Initialize());
            SiiFileReader reader = new SiiFileReader(gameFs.GetIncludeProvider("def"));

            Task.WaitAll(reader.ReadSiiFile(gameFs.OpenFile("def/country.sii")));
        }
Exemple #3
0
        public void TestInclusion()
        {
            IInclusionProvider provider = new TestInclusionProvider(GetResourceStream);
            SiiFileReader      readerWithInclusionProvider    = new SiiFileReader(provider);
            SiiFileReader      readerWithoutInclusionProvider = new SiiFileReader();

            using (Stream includerStream = GetResourceStream("IncluderUnit")) {
                Assert.ThrowsExceptionAsync <InvalidOperationException>(async delegate {
                    await readerWithInclusionProvider.ReadFromText(includerStream);
                });
            }

            using (Stream includerStream = GetResourceStream("IncluderUnit")) {
                Object obj = readerWithInclusionProvider.ReadSiiFile(includerStream).Result;

                Assert.IsTrue(obj.Attributes.ContainsKey("attr1"));
                Assert.IsTrue(obj.Attributes.ContainsKey("attr2"));
                Assert.IsFalse(obj.Attributes.ContainsKey("attr_non_existing"));
            }
        }
Exemple #4
0
        public async Task TestSerializeObject()
        {
            string tmpPath = Path.GetTempFileName();

            try {
                using (FileStream fs = new FileStream(tmpPath, FileMode.Create, FileAccess.Write)) {
                    MemoryStream  ms     = new MemoryStream(Resources.Samples.GameText);
                    SiiFileReader reader = new SiiFileReader();
                    Object        obj    = await reader.ReadSiiFile(ms);

                    byte[] b = Encoding.UTF8.GetBytes(ObjectSerializer.SerializeObject(obj));
                    fs.Write(b, 0, b.Length);
                }
            } finally {
                if (File.Exists(tmpPath))
                {
                    File.Delete(tmpPath);
                }
            }
        }