예제 #1
0
 private static void AssertUpgrade(MyUpgradedAsset asset)
 {
     Assert.Equal(new PackageVersion("0.0.5"), asset.SerializedVersion["TestPackage"]);
     Assert.Null(asset.Test1);
     Assert.Null(asset.Test2);
     Assert.Null(asset.Test3);
     Assert.Null(asset.Test4);
     Assert.NotNull(asset.Test5);
 }
예제 #2
0
 private static void AssertUpgrade(MyUpgradedAsset asset)
 {
     Assert.That(asset.SerializedVersion, Is.EqualTo(5));
     Assert.That(asset.Test1, Is.Null);
     Assert.That(asset.Test2, Is.Null);
     Assert.That(asset.Test3, Is.Null);
     Assert.That(asset.Test4, Is.Null);
     Assert.That(asset.Test5, Is.Not.Null);
 }
예제 #3
0
 private static void AssertUpgrade(MyUpgradedAsset asset)
 {
     Assert.That(asset.SerializedVersion["TestPackage"], Is.EqualTo(new PackageVersion("0.0.5")));
     Assert.That(asset.Test1, Is.Null);
     Assert.That(asset.Test2, Is.Null);
     Assert.That(asset.Test3, Is.Null);
     Assert.That(asset.Test4, Is.Null);
     Assert.That(asset.Test5, Is.Not.Null);
 }
예제 #4
0
        public void Version5()
        {
            var asset = new MyUpgradedAsset(5)
            {
                Vector = new Vector3(12.0f, 15.0f, 17.0f), Test5 = new List <int> {
                    32, 64
                }
            };

            TestUpgrade(asset, false);
        }
예제 #5
0
        public void Version4()
        {
            var asset = new MyUpgradedAsset(4)
            {
                Vector = new Vector3(12.0f, 15.0f, 17.0f), Test4 = new List <int> {
                    32, 64
                }
            };

            TestUpgrade(asset, true);
        }
예제 #6
0
        public void TestUpgrade(MyUpgradedAsset asset, bool needMigration)
        {
            var outputFilePath = Path.Combine(DirectoryTestBase, @"TestUpgrade\Asset1.pdxobj");

            AssetSerializer.Save(outputFilePath, asset);

            var logger = new LoggerResult();

            Assert.AreEqual(AssetMigration.MigrateAssetIfNeeded(logger, outputFilePath), needMigration);

            Console.WriteLine(File.ReadAllText(outputFilePath).Trim());

            var upgradedAsset = AssetSerializer.Load <MyUpgradedAsset>(outputFilePath);

            AssertUpgrade(upgradedAsset);
        }
예제 #7
0
        public void TestUpgrade(MyUpgradedAsset asset, bool needMigration)
        {
            var loadingFilePath = new PackageLoadingAssetFile(Path.Combine(DirectoryTestBase, "TestUpgrade\\Asset1.pdxobj"), "");
            var outputFilePath  = loadingFilePath.FilePath.FullPath;

            AssetSerializer.Save(outputFilePath, asset);

            var logger = new LoggerResult();

            Assert.AreEqual(AssetMigration.MigrateAssetIfNeeded(logger, loadingFilePath), needMigration);

            if (needMigration)
            {
                using (var fileStream = new FileStream(outputFilePath, FileMode.Truncate))
                    fileStream.Write(loadingFilePath.AssetContent, 0, loadingFilePath.AssetContent.Length);
            }

            Console.WriteLine(File.ReadAllText(outputFilePath).Trim());

            var upgradedAsset = AssetSerializer.Load <MyUpgradedAsset>(outputFilePath);

            AssertUpgrade(upgradedAsset);
        }
예제 #8
0
        public void Simple()
        {
            var asset = new MyUpgradedAsset {
                Test = 32, Test2 = new List <int> {
                    32, 64
                }
            };
            var outputFilePath = Path.Combine(DirectoryTestBase, @"TestUpgrade\Asset1.pdxobj");

            AssetSerializer.Save(outputFilePath, asset);

            var logger = new LoggerResult();

            Assert.That(AssetMigration.MigrateAssetIfNeeded(logger, outputFilePath));

            Console.WriteLine(File.ReadAllText(outputFilePath).Trim());

            var upgradedAsset = AssetSerializer.Load <MyUpgradedAsset>(outputFilePath);

            Assert.That(upgradedAsset.SerializedVersion, Is.EqualTo(2));
            Assert.That(upgradedAsset.Test2, Is.Null);
            Assert.That(upgradedAsset.Test3, Is.Not.Null);
        }
예제 #9
0
        private void TestUpgrade(MyUpgradedAsset asset, bool needMigration)
        {
            var loadingFilePath = new PackageLoadingAssetFile(Path.Combine(DirectoryTestBase, "TestUpgrade\\Asset1.sdobj"), DirectoryTestBase);
            var outputFilePath  = loadingFilePath.FilePath.FullPath;

            AssetFileSerializer.Save(outputFilePath, asset, null);

            var logger  = new LoggerResult();
            var context = new AssetMigrationContext(null, loadingFilePath.ToReference(), loadingFilePath.FilePath.ToWindowsPath(), logger);

            Assert.Equal(AssetMigration.MigrateAssetIfNeeded(context, loadingFilePath, "TestPackage"), needMigration);

            if (needMigration)
            {
                using (var fileStream = new FileStream(outputFilePath, FileMode.Truncate))
                    fileStream.Write(loadingFilePath.AssetContent, 0, loadingFilePath.AssetContent.Length);
            }

            Console.WriteLine(File.ReadAllText(outputFilePath).Trim());

            var upgradedAsset = AssetFileSerializer.Load <MyUpgradedAsset>(outputFilePath).Asset;

            AssertUpgrade(upgradedAsset);
        }
예제 #10
0
 public void Version1()
 {
     var asset = new MyUpgradedAsset(1) { Vector = new Vector3(12.0f, 15.0f, 17.0f), Test1 = new List<int> { 32, 64 } };
     TestUpgrade(asset, true);
 }
예제 #11
0
 private static void AssertUpgrade(MyUpgradedAsset asset)
 {
     Assert.That(asset.SerializedVersion["TestPackage"], Is.EqualTo(new PackageVersion("0.0.5")));
     Assert.That(asset.Test1, Is.Null);
     Assert.That(asset.Test2, Is.Null);
     Assert.That(asset.Test3, Is.Null);
     Assert.That(asset.Test4, Is.Null);
     Assert.That(asset.Test5, Is.Not.Null);
 }
예제 #12
0
        public void TestUpgrade(MyUpgradedAsset asset, bool needMigration)
        {
            var loadingFilePath = new PackageLoadingAssetFile(Path.Combine(DirectoryTestBase, "TestUpgrade\\Asset1.xkobj"), "");
            var outputFilePath = loadingFilePath.FilePath.FullPath;
            AssetSerializer.Save(outputFilePath, asset);

            var logger = new LoggerResult();
            var context = new AssetMigrationContext(null, logger);
            Assert.AreEqual(AssetMigration.MigrateAssetIfNeeded(context, loadingFilePath, "TestPackage"), needMigration);

            if (needMigration)
            {
                using (var fileStream = new FileStream(outputFilePath, FileMode.Truncate))
                    fileStream.Write(loadingFilePath.AssetContent, 0, loadingFilePath.AssetContent.Length);
            }

            Console.WriteLine(File.ReadAllText(outputFilePath).Trim());

            var upgradedAsset = AssetSerializer.Load<MyUpgradedAsset>(outputFilePath);
            AssertUpgrade(upgradedAsset);
        }
예제 #13
0
 public void Version5()
 {
     var asset = new MyUpgradedAsset(5) { Vector = new Vector3(12.0f, 15.0f, 17.0f), Test5 = new List<int> { 32, 64 } };
     TestUpgrade(asset, false);
 }
예제 #14
0
 private static void AssertUpgrade(MyUpgradedAsset asset)
 {
     Assert.That(asset.SerializedVersion, Is.EqualTo(5));
     Assert.That(asset.Test1, Is.Null);
     Assert.That(asset.Test2, Is.Null);
     Assert.That(asset.Test3, Is.Null);
     Assert.That(asset.Test4, Is.Null);
     Assert.That(asset.Test5, Is.Not.Null);
 }
예제 #15
0
        public void TestUpgrade(MyUpgradedAsset asset, bool needMigration)
        {
            var outputFilePath = Path.Combine(DirectoryTestBase, @"TestUpgrade\Asset1.pdxobj");
            AssetSerializer.Save(outputFilePath, asset);

            var logger = new LoggerResult();
            Assert.AreEqual(AssetMigration.MigrateAssetIfNeeded(logger, outputFilePath), needMigration);

            Console.WriteLine(File.ReadAllText(outputFilePath).Trim());

            var upgradedAsset = AssetSerializer.Load<MyUpgradedAsset>(outputFilePath);
            AssertUpgrade(upgradedAsset);
        }