Exemplo n.º 1
0
        public void Zenkaku()
        {
            Assert.True(Engine.Initialize("Altseed2 C# Engine", 800, 600, new Configuration()));

            // pack files
            Assert.True(Engine.File.Pack("../../Core/TestData/IO/", "pack.pack"));

            // add package
            Assert.True(Engine.File.AddRootPackage("pack.pack"));

            StaticFile test1     = null;
            StaticFile test2     = null;
            StaticFile testPack1 = null;
            StaticFile testPack2 = null;

            test1     = StaticFile.Create("../../Core/TestData/IO/全角 テスト.txt");
            test2     = StaticFile.Create("../../Core/TestData/IO/全角 テスト.txt");
            testPack1 = StaticFile.Create("全角 テスト.txt");
            testPack2 = StaticFile.Create("全角 テスト.txt");

            Assert.AreNotEqual(test1, null);
            Assert.AreNotEqual(test2, null);
            Assert.AreNotEqual(testPack1, null);
            Assert.AreNotEqual(testPack2, null);

            Assert.AreNotEqual(test1.Size, 0);
            Assert.AreNotEqual(test2.Size, 0);
            Assert.AreNotEqual(testPack1.Size, 0);
            Assert.AreNotEqual(testPack2.Size, 0);

            Engine.Terminate();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            // Altseed を初期化します。
            if (!Engine.Initialize("Serialization", 640, 480, new Configuration()))
            {
                return;
            }

            // シリアライズ結果を保存するファイルのパス
            var path = "SerializeSample.bin";

            // StaticFileを生成。
            var file1 = StaticFile.Create(@"TestData\IO\test.txt");

            // fileをシリアライズします。
            Serialize(path, file1);

            // シリアライズされたfileをデシリアライズします。
            var file2 = (StaticFile)DeSerialize(path);

            // バイト配列をUTF8として、string型に変換します。
            var text1 = Encoding.UTF8.GetString(file1.Buffer);
            var text2 = Encoding.UTF8.GetString(file2.Buffer);

            // テキストをコンソールに出力します。
            Console.WriteLine("text1 : {0}", text1);
            Console.WriteLine("text2 : {0}", text2);

            // Altseed の終了処理をします。
            Engine.Terminate();
        }
Exemplo n.º 3
0
        public void StaticFileAsync()
        {
            Assert.True(Engine.Initialize("Altseed2 C# Engine", 800, 600, new Configuration()));

            // pack files
            Assert.True(Engine.File.Pack("../../Core/TestData/IO/", "pack.pack"));

            // add package
            Assert.True(Engine.File.AddRootPackage("pack.pack"));

            // create static file, and compare no-package and package without password
            StaticFile test1         = null;
            StaticFile test2         = null;
            StaticFile test3         = null;
            StaticFile test4         = null;
            StaticFile testCache     = null;
            StaticFile testPack1     = null;
            StaticFile testPack2     = null;
            StaticFile testPack3     = null;
            StaticFile testPack4     = null;
            StaticFile testPackCache = null;

            var task1 = Task.Run(() => {
                test1     = StaticFile.Create("../../Core/TestData/IO/test.txt");
                test3     = StaticFile.Create("../../Core/TestData/IO/全角 テスト.txt");
                testPack1 = StaticFile.Create("test.txt");
                testPack3 = StaticFile.Create("全角 テスト.txt");
                testCache = StaticFile.Create("../../Core/TestData/IO/test.txt");
            });

            var task2 = Task.Run(() => {
                test2         = StaticFile.Create("../../Core/TestData/IO/space test.txt");
                test4         = StaticFile.Create("../../Core/TestData/IO/全角 テスト.txt");
                testPack2     = StaticFile.Create("space test.txt");
                testPack4     = StaticFile.Create("全角 テスト.txt");
                testPackCache = StaticFile.Create("space test.txt");
            });

            task1.Wait();
            task2.Wait();

            Assert.AreNotEqual(test1, null);
            Assert.AreNotEqual(test2, null);
            Assert.AreNotEqual(test3, null);
            Assert.AreNotEqual(test4, null);
            Assert.AreNotEqual(testCache, null);
            Assert.AreNotEqual(testPack1, null);
            Assert.AreNotEqual(testPack2, null);
            Assert.AreNotEqual(testPack3, null);
            Assert.AreNotEqual(testPack4, null);
            Assert.AreNotEqual(testPackCache, null);

            Assert.AreEqual(test1.Size, testPack1.Size);
            Assert.AreEqual(test1.Size, testPack1.Size);
            Assert.AreEqual(test2.Size, testPack2.Size);
            Assert.AreEqual(test3.Size, testPack3.Size);
            Assert.AreEqual(test4.Size, testPack4.Size);

            Engine.Terminate();
        }
Exemplo n.º 4
0
        public void Zenkaku()
        {
            var tc = new TestCore();

            tc.Init();

            // pack files
            Assert.True(Engine.File.Pack("TestData/IO/", "pack.pack"));

            // add package
            Assert.True(Engine.File.AddRootPackage("pack.pack"));

            StaticFile test1     = null;
            StaticFile test2     = null;
            StaticFile testPack1 = null;
            StaticFile testPack2 = null;

#if !CI
            test1     = StaticFile.Create("TestData/IO/全角 テスト.txt");
            test2     = StaticFile.Create("TestData/IO/全角 テスト.txt");
            testPack1 = StaticFile.Create("全角 テスト.txt");
            testPack2 = StaticFile.Create("全角 テスト.txt");

            Assert.AreNotEqual(test1, null);
            Assert.AreNotEqual(testPack1, null);
            Assert.AreNotEqual(test2, null);
            Assert.AreNotEqual(testPack2, null);
            Assert.AreNotEqual(test1.Size, 0);
            Assert.AreNotEqual(testPack1.Size, 0);
            Assert.AreNotEqual(test2.Size, 0);
            Assert.AreNotEqual(testPack2.Size, 0);
#endif

            tc.End();
        }
Exemplo n.º 5
0
        public void StaticFileBase()
        {
            var tc = new TestCore();

            tc.Init();

            // pack files
            Assert.True(Engine.File.Pack("TestData/IO/", "pack.pack"));
            Assert.True(Engine.File.PackWithPassword("TestData/IO/pack/", "password.pack", "altseed"));

            // add package
            Assert.True(Engine.File.AddRootPackage("pack.pack"));

            // create static file, and compare no-package and package without password
            StaticFile test = null;

            Assert.AreNotEqual(test = StaticFile.Create("TestData/IO/test.txt"), null);
            Assert.False(test.IsInPackage);
            StaticFile testPack = null;

            Assert.AreNotEqual(testPack = StaticFile.Create("test.txt"), null);
            Assert.True(testPack.IsInPackage);
            Assert.AreEqual(test.Size, testPack.Size);

            // add package
            Assert.True(Engine.File.AddRootPackageWithPassword("password.pack", "altseed"));

            // clear cache
            Engine.Resources.Clear();

            StaticFile testPack2 = null;

            Assert.AreNotEqual(testPack2 = StaticFile.Create("test.txt"), null);
            Assert.True(testPack2.IsInPackage);
            Assert.AreNotEqual(testPack, testPack2);
            Assert.AreNotEqual(testPack.Size, testPack2.Size);

            // create static file, and compare no-package and package with password
            StaticFile test3 = null;

            Assert.AreNotEqual(test3 = StaticFile.Create("TestData/IO/pack/test.txt"), null);
            Assert.AreEqual(test3.Size, testPack2.Size);
            Assert.AreEqual(test3.Size, testPack2.Size);

            tc.End();
        }
Exemplo n.º 6
0
        public void UtilityStaticFile()
        {
            StaticFile file = StaticFile.Create("~/collar.ashx", "js/collar.js");

            Assert.IsNotNull(file);
            Assert.IsFalse(string.IsNullOrEmpty(file.Hash));
            Assert.IsTrue(file.Url.StartsWith("/collar.ashx", StringComparison.OrdinalIgnoreCase));
            Assert.AreEqual("text/javascript", file.ContentType);

            file = StaticFile.Create("~/collar.ashx", "img/logo-header.png");
            Assert.IsNotNull(file);
            Assert.AreEqual("image/png", file.ContentType);

            file = StaticFile.Create("~/collar.ashx", "index.xslt");
            Assert.IsNotNull(file);
            Assert.AreEqual("text/html", file.ContentType);
        }
Exemplo n.º 7
0
        public void StaticFileBase()
        {
            Assert.True(Engine.Initialize("Altseed2 C# Engine", 800, 600, new Configuration()));

            // pack files
            Assert.True(Engine.File.Pack("../../Core/TestData/IO/", "pack.pack"));
            Assert.True(Engine.File.PackWithPassword("../../Core/TestData/IO/pack/", "password.pack", "altseed"));

            // add package
            Assert.True(Engine.File.AddRootPackage("pack.pack"));

            // create static file, and compare no-package and package without password
            StaticFile test = null;

            Assert.AreNotEqual(test = StaticFile.Create("../../Core/TestData/IO/test.txt"), null);
            Assert.False(test.IsInPackage);
            StaticFile testPack = null;

            Assert.AreNotEqual(testPack = StaticFile.Create("test.txt"), null);
            Assert.True(testPack.IsInPackage);
            Assert.AreEqual(test.Size, testPack.Size);

            // add package
            Assert.True(Engine.File.AddRootPackageWithPassword("password.pack", "altseed"));

            // clear cache
            Engine.Resources.Clear();

            StaticFile testPack2 = null;

            Assert.AreNotEqual(testPack2 = StaticFile.Create("test.txt"), null);
            Assert.True(testPack2.IsInPackage);
            Assert.AreNotEqual(testPack, testPack2);
            Assert.AreNotEqual(testPack.Size, testPack2.Size);

            // create static file, and compare no-package and package with password
            StaticFile test3 = null;

            Assert.AreNotEqual(test3 = StaticFile.Create("../../Core/TestData/IO/pack/test.txt"), null);
            Assert.AreEqual(test3.Size, testPack2.Size);
            Assert.AreEqual(test3.Size, testPack2.Size);

            Engine.Terminate();
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            // Altseed を初期化します。
            if (!Engine.Initialize("StaticFile", 640, 480, new Configuration()))
            {
                return;
            }

            // ファイルを読み込みます。
            var staticFile = StaticFile.Create(@"TestData\IO\test.txt");

            // バイト配列をUTF8として、string型に変換します。
            var text = Encoding.UTF8.GetString(staticFile.Buffer);

            // コンソールに出力します。
            Console.WriteLine(text);

            // Altseed の終了処理をします。
            Engine.Terminate();
        }
Exemplo n.º 9
0
        public void StaticFileCache()
        {
            var tc = new TestCore();

            tc.Init();

            var path = System.IO.Path.GetFullPath("TestData/IO/AltseedPink.png");

            Assert.True(Engine.File.Exists(path));
            StaticFile test = null;

            Assert.AreNotEqual(test = StaticFile.Create(path), null);

            StaticFile test3 = null;

            Assert.AreNotEqual(test3 = StaticFile.Create(path), null);

            Engine.Log.Info(LogCategory.Engine, $"{test.selfPtr}/{test3.selfPtr}");
            Engine.Log.Info(LogCategory.Engine, Engine.Resources.GetResourcesCount(ResourceType.StaticFile).ToString());
            tc.End();
        }
Exemplo n.º 10
0
        public void StaticFileCache()
        {
            Assert.True(Engine.Initialize("Altseed2 C# Engine", 800, 600, new Configuration()
            {
                FileLoggingEnabled = true, LogFileName = "cache.txt", ConsoleLoggingEnabled = true
            }));

            var path = System.IO.Path.GetFullPath("../../Core/TestData/IO/AltseedPink.png");

            Assert.True(Engine.File.Exists(path));
            StaticFile test = null;

            Assert.AreNotEqual(test = StaticFile.Create(path), null);

            StaticFile test3 = null;

            Assert.AreNotEqual(test3 = StaticFile.Create(path), null);

            Engine.Log.Info(LogCategory.Engine, $"{test.selfPtr}/{test3.selfPtr}");
            Engine.Log.Info(LogCategory.Engine, Engine.Resources.GetResourcesCount(ResourceType.StaticFile).ToString());
            Engine.Terminate();
        }
Exemplo n.º 11
0
        public void StaticFileAsync()
        {
            var tc = new TestCore();

            tc.Init();

            // pack files
            Assert.True(Engine.File.Pack("TestData/IO/", "pack.pack"));

            // add package
            Assert.True(Engine.File.AddRootPackage("pack.pack"));

            // create static file, and compare no-package and package without password
            StaticFile test1 = null;
            StaticFile test2 = null;

#if !CI
            StaticFile test3 = null;
            StaticFile test4 = null;
#endif
            StaticFile testCache = null;
            StaticFile testPack1 = null;
            StaticFile testPack2 = null;
#if !CI
            StaticFile testPack3 = null;
            StaticFile testPack4 = null;
#endif
            StaticFile testPackCache = null;

            var task1 = Task.Run(() =>
            {
                test1 = StaticFile.Create("TestData/IO/test.txt");
#if !CI
                test3 = StaticFile.Create("TestData/IO/全角 テスト.txt");
#endif
                testPack1 = StaticFile.Create("test.txt");
#if !CI
                testPack3 = StaticFile.Create("全角 テスト.txt");
#endif
                testCache = StaticFile.Create("TestData/IO/test.txt");
            });

            var task2 = Task.Run(() =>
            {
                test2 = StaticFile.Create("TestData/IO/space test.txt");
#if !CI
                test4 = StaticFile.Create("TestData/IO/全角 テスト.txt");
#endif
                testPack2 = StaticFile.Create("space test.txt");
#if !CI
                testPack4 = StaticFile.Create("全角 テスト.txt");
#endif
                testPackCache = StaticFile.Create("space test.txt");
            });

            task1.Wait();
            task2.Wait();

            Assert.AreNotEqual(test1, null);
            Assert.AreNotEqual(test2, null);
#if !CI
            Assert.AreNotEqual(test3, null);
            Assert.AreNotEqual(test4, null);
#endif
            Assert.AreNotEqual(testCache, null);
            Assert.AreNotEqual(testPack1, null);
            Assert.AreNotEqual(testPack2, null);
#if !CI
            Assert.AreNotEqual(testPack3, null);
            Assert.AreNotEqual(testPack4, null);
#endif
            Assert.AreNotEqual(testPackCache, null);

            Assert.AreEqual(test1.Size, testPack1.Size);
            Assert.AreEqual(test2.Size, testPack2.Size);
#if !CI
            Assert.AreEqual(test3.Size, testPack3.Size);
            Assert.AreEqual(test4.Size, testPack4.Size);
#endif
            tc.End();
        }