public void buildSelectedAndLoadTest() { using (ResourceManager manager = ResourceManagerTests.createManager()) { using (ResourcesInfo info = ScriptableObject.CreateInstance <ResourcesInfo>()) { usingTempFile(() => { ResourcesInfoEditor.build(info, PATH_BUILD_OUTPUT, new ResourceInfo() { type = ResourceType.Resources, path = PATH_RESOURCE_TO_LOAD }, new ResourceInfo() { type = ResourceType.Assetbundle, path = PATH_ASSET_TO_PACK, }, new ResourceInfo() { type = ResourceType.File, path = PATH_FILE_TO_READ }); manager.resourcesInfo = info; loadAllKindResAssert(manager); }); } } }
public void buildAndCheckInfoTest() { using (ResourcesInfo info = ScriptableObject.CreateInstance <ResourcesInfo>()) { usingTempFile(() => { ResourcesInfoEditor.build(info, PATH_BUILD_OUTPUT); Assert.AreEqual(PATH_BUILD_OUTPUT, info.bundleOutputPath); var resourceToLoad = info.resourceList.Find(r => r.type == ResourceType.Resources && r.path == PATH_RESOURCE_TO_LOAD); Assert.NotNull(resourceToLoad); var resourceNotToLoad = info.resourceList.Find(r => r.path == PATH_RESOURCE_NOT_TO_LOAD); Assert.Null(resourceNotToLoad); Assert.False(info.resourceList.Exists(r => r.type == ResourceType.Resources && Path.GetFileNameWithoutExtension(r.path) == nameof(ResourceManager))); var fileToRead = info.resourceList.Find(r => r.type == ResourceType.File && r.path == PATH_FILE_TO_READ); Assert.NotNull(fileToRead); var assetToPack = info.resourceList.Find(r => r.type == ResourceType.Assetbundle && r.path == PATH_ASSET_TO_PACK.ToLower()); Assert.NotNull(assetToPack); }); } }
IEnumerator createManagerBuildAndAssertAsync(Func <ResourceManager, IEnumerator> onAssert, bool reCreate = false) { if (!reCreate && manager != null) { bool isFileTemp = false; if (!Directory.Exists(Path.GetDirectoryName(PATH_FILE_TO_READ))) { Directory.CreateDirectory(Path.GetDirectoryName(PATH_FILE_TO_READ)); } if (!File.Exists(PATH_FILE_TO_READ)) { isFileTemp = true; File.Create(PATH_FILE_TO_READ).Close(); } yield return(onAssert?.Invoke(manager)); if (isFileTemp) { File.Delete(PATH_FILE_TO_READ); } yield break; } using (manager = ResourceManagerTests.createManager()) { using (ResourcesInfo info = ScriptableObject.CreateInstance <ResourcesInfo>()) { bool isFileTemp = false; if (!Directory.Exists(Path.GetDirectoryName(PATH_FILE_TO_READ))) { Directory.CreateDirectory(Path.GetDirectoryName(PATH_FILE_TO_READ)); } if (!File.Exists(PATH_FILE_TO_READ)) { isFileTemp = true; File.Create(PATH_FILE_TO_READ).Close(); } ResourcesInfoEditor.build(info, PATH_BUILD_OUTPUT); manager.resourcesInfo = info; yield return(onAssert?.Invoke(manager)); if (isFileTemp) { File.Delete(PATH_FILE_TO_READ); } } } manager = null; }
private void createManagerBuildAndAssert(Action <ResourceManager> onAssert, bool reCreate = true) { if (!reCreate && manager != null) { usingTempFile(() => { onAssert?.Invoke(manager); }); return; } using (manager = ResourceManagerTests.createManager()) { using (ResourcesInfo info = ScriptableObject.CreateInstance <ResourcesInfo>()) { usingTempFile(() => { ResourcesInfoEditor.build(info, PATH_BUILD_OUTPUT); manager.resourcesInfo = info; onAssert?.Invoke(manager); }); } } manager = null; }