public void ApplyAssetEntryUpdates_DeletesCorrectBundle() { File.WriteAllText(k_ContentUpdateTestCachedBundlePath, "TestCachedAssetBundle"); File.WriteAllText(k_ContentUpdateTestNewBundleName, "TestAssetBundle"); var group = Settings.CreateGroup("ContentUpdateTests", false, false, false, null, typeof(BundledAssetGroupSchema), typeof(ContentUpdateGroupSchema)); string contentUpdateTestGroupGuid = GUID.Generate().ToString(); group.GetSchema <ContentUpdateGroupSchema>().StaticContent = false; var assetEntry = CreateAssetEntry(m_ContentUpdateTestAssetGUID, group); group.AddAssetEntry(assetEntry); var context = GetContentUpdateContext(m_ContentUpdateTestAssetGUID, k_ContentUpdateTestCachedAssetHash, k_ContentUpdateTestNewInternalBundleName, k_ContentUpdateTestNewBundleName, k_ContentUpdateTestCachedBundlePath, contentUpdateTestGroupGuid, k_ContentUpdateTestFileName); var ops = new List <RevertUnchangedAssetsToPreviousAssetState.AssetEntryRevertOperation>() { new RevertUnchangedAssetsToPreviousAssetState.AssetEntryRevertOperation() { PreviousBuildPath = k_ContentUpdateTestCachedBundlePath, AssetEntry = assetEntry, BundleCatalogEntry = context.IdToCatalogDataEntryMap[m_ContentUpdateTestAssetGUID], CurrentBuildPath = k_ContentUpdateTestNewBundleName, PreviousAssetState = context.GuidToPreviousAssetStateMap[m_ContentUpdateTestAssetGUID] }, new RevertUnchangedAssetsToPreviousAssetState.AssetEntryRevertOperation() { PreviousBuildPath = k_ContentUpdateTestCachedBundlePath, AssetEntry = assetEntry, BundleCatalogEntry = context.IdToCatalogDataEntryMap[m_ContentUpdateTestAssetGUID], CurrentBuildPath = k_ContentUpdateTestNewBundleName, PreviousAssetState = context.GuidToPreviousAssetStateMap[m_ContentUpdateTestAssetGUID] } }; RevertUnchangedAssetsToPreviousAssetState.ApplyAssetEntryUpdates(ops, "BundleProvider", new List <ContentCatalogDataEntry>(), context); Assert.IsTrue(File.Exists(k_ContentUpdateTestCachedBundlePath)); Assert.IsFalse(File.Exists(k_ContentUpdateTestNewBundleName)); File.Delete(k_ContentUpdateTestCachedBundlePath); Settings.RemoveGroup(group); }
public void ApplyAssetEntryUpdates_InvalidKeyForGuidToPreviousAssetStateMap_DoesNotThrow() { File.WriteAllText(k_ContentUpdateTestCachedBundlePath, "TestCachedAssetBundle"); var group = Settings.CreateGroup("ContentUpdateTests", false, false, false, null, typeof(BundledAssetGroupSchema), typeof(ContentUpdateGroupSchema)); string contentUpdateTestGroupGuid = GUID.Generate().ToString(); group.GetSchema <ContentUpdateGroupSchema>().StaticContent = false; var assetEntry = CreateAssetEntry(m_ContentUpdateTestAssetGUID, group); group.AddAssetEntry(assetEntry); var context = GetContentUpdateContext(m_ContentUpdateTestAssetGUID, k_ContentUpdateTestCachedAssetHash, k_ContentUpdateTestNewInternalBundleName, k_ContentUpdateTestNewBundleName, k_ContentUpdateTestCachedBundlePath, contentUpdateTestGroupGuid, k_ContentUpdateTestFileName); context.GuidToPreviousAssetStateMap[m_ContentUpdateTestAssetGUID].dependencies = new AssetState[] { new AssetState() { guid = GUID.Generate(), hash = Hash128.Parse("9823749283742") } }; var ops = new List <RevertUnchangedAssetsToPreviousAssetState.AssetEntryRevertOperation>() { new RevertUnchangedAssetsToPreviousAssetState.AssetEntryRevertOperation() { PreviousBuildPath = k_ContentUpdateTestCachedBundlePath, AssetEntry = assetEntry, BundleCatalogEntry = context.IdToCatalogDataEntryMap[m_ContentUpdateTestAssetGUID], CurrentBuildPath = k_ContentUpdateTestNewBundleName, PreviousAssetState = context.GuidToPreviousAssetStateMap[m_ContentUpdateTestAssetGUID] } }; Assert.DoesNotThrow(() => RevertUnchangedAssetsToPreviousAssetState.ApplyAssetEntryUpdates(ops, "BundleProvider", new List <ContentCatalogDataEntry>(), context)); File.Delete(k_ContentUpdateTestCachedBundlePath); Settings.RemoveGroup(group); }
public void ApplyAssetEntryUpdates_RegistryOnlyContainsCachedBundleEntry() { var group = Settings.CreateGroup("ContentUpdateTests", false, false, false, null, typeof(BundledAssetGroupSchema), typeof(ContentUpdateGroupSchema)); string contentUpdateTestGroupGuid = GUID.Generate().ToString(); group.GetSchema <ContentUpdateGroupSchema>().StaticContent = false; var assetEntry = CreateAssetEntry(m_ContentUpdateTestAssetGUID, group); group.AddAssetEntry(assetEntry); var context = GetContentUpdateContext(m_ContentUpdateTestAssetGUID, k_ContentUpdateTestCachedAssetHash, k_ContentUpdateTestNewInternalBundleName, k_ContentUpdateTestNewBundleName, k_ContentUpdateTestCachedBundlePath, contentUpdateTestGroupGuid, k_ContentUpdateTestFileName); var ops = new List <RevertUnchangedAssetsToPreviousAssetState.AssetEntryRevertOperation>() { new RevertUnchangedAssetsToPreviousAssetState.AssetEntryRevertOperation() { PreviousBuildPath = k_ContentUpdateTestCachedBundlePath, AssetEntry = assetEntry, BundleCatalogEntry = context.IdToCatalogDataEntryMap[m_ContentUpdateTestAssetGUID], CurrentBuildPath = k_ContentUpdateTestNewBundleName, PreviousAssetState = context.GuidToPreviousAssetStateMap[m_ContentUpdateTestAssetGUID] }, new RevertUnchangedAssetsToPreviousAssetState.AssetEntryRevertOperation() { PreviousBuildPath = k_ContentUpdateTestCachedBundlePath, AssetEntry = assetEntry, BundleCatalogEntry = context.IdToCatalogDataEntryMap[m_ContentUpdateTestAssetGUID], CurrentBuildPath = k_ContentUpdateTestNewBundleName, PreviousAssetState = context.GuidToPreviousAssetStateMap[m_ContentUpdateTestAssetGUID] } }; RevertUnchangedAssetsToPreviousAssetState.ApplyAssetEntryUpdates(ops, "BundleProvider", new List <ContentCatalogDataEntry>(), context); var registryPaths = context.Registry.GetFilePaths(); Assert.AreEqual(1, registryPaths.Count()); Assert.AreEqual(k_ContentUpdateTestCachedBundlePath, registryPaths.ElementAt(0)); Settings.RemoveGroup(group); }
public void ApplyAssetEntryUpdates_PreviousStateDependencies_SetInCatalogEntry() { var group = Settings.CreateGroup("ContentUpdateTests", false, false, false, null, typeof(BundledAssetGroupSchema), typeof(ContentUpdateGroupSchema)); string contentUpdateTestGroupGuid = GUID.Generate().ToString(); group.GetSchema <ContentUpdateGroupSchema>().StaticContent = false; var assetEntry = CreateAssetEntry(m_ContentUpdateTestAssetGUID, group); group.AddAssetEntry(assetEntry); var context = GetContentUpdateContext(m_ContentUpdateTestAssetGUID, k_ContentUpdateTestCachedAssetHash, k_ContentUpdateTestNewInternalBundleName, k_ContentUpdateTestNewBundleName, k_ContentUpdateTestCachedBundlePath, contentUpdateTestGroupGuid, k_ContentUpdateTestFileName); var previousDep = new AssetState() { guid = GUID.Generate(), hash = Hash128.Parse("9823749283742") }; var currentDep = new AssetState() { guid = GUID.Generate(), hash = Hash128.Parse("128747239872") }; context.GuidToPreviousAssetStateMap[m_ContentUpdateTestAssetGUID].dependencies = new AssetState[] { previousDep }; context.IdToCatalogDataEntryMap[m_ContentUpdateTestAssetGUID].Dependencies.Add(currentDep); var ops = new List <RevertUnchangedAssetsToPreviousAssetState.AssetEntryRevertOperation>() { new RevertUnchangedAssetsToPreviousAssetState.AssetEntryRevertOperation() { PreviousBuildPath = k_ContentUpdateTestCachedBundlePath, AssetEntry = assetEntry, BundleCatalogEntry = context.IdToCatalogDataEntryMap[m_ContentUpdateTestAssetGUID], CurrentBuildPath = k_ContentUpdateTestNewBundleName, PreviousAssetState = context.GuidToPreviousAssetStateMap[m_ContentUpdateTestAssetGUID] } }; string depBundleFileId = "depBundleFileId"; context.GuidToPreviousAssetStateMap.Add(previousDep.guid.ToString(), new CachedAssetState() { asset = previousDep, bundleFileId = depBundleFileId, data = previousDep, dependencies = new AssetState[0], groupGuid = contentUpdateTestGroupGuid }); var locations = new List <ContentCatalogDataEntry>(); RevertUnchangedAssetsToPreviousAssetState.ApplyAssetEntryUpdates(ops, "BundleProvider", locations, context); Assert.AreEqual(1, locations.Count); Assert.AreEqual(1, ops[0].BundleCatalogEntry.Dependencies.Count); Assert.AreEqual(depBundleFileId + ops[0].AssetEntry.GetHashCode(), ops[0].BundleCatalogEntry.Dependencies[0]); Settings.RemoveGroup(group); }