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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }