public void GetMaterialConstructor_NonExistentMatLib_ReturnsNull() { mtlLibrary.ContentLoader = FakeContentLoaderFactory.CreateFakeLoader(content); MaterialConstructor res = mtlLibrary.GetMaterialConstructor("", ""); Assert.IsNull(res); }
public IEnumerator ExtendedLogging_Disabled_CommentsNotLogged() { mtlLibrary.ContentLoader = FakeContentLoaderFactory.CreateFakeLoader(content); mtlLibrary.ExtendedLogging = false; Task task = LoadLibrary(); yield return(AsyncTest.WaitForTask(task)); LogAssert.NoUnexpectedReceived(); }
public IEnumerator ExtendedLogging_Enabled_CommentsLogged() { mtlLibrary.ContentLoader = FakeContentLoaderFactory.CreateFakeLoader(content); mtlLibrary.ExtendedLogging = true; Task task = LoadLibrary(); yield return(AsyncTest.WaitForTask(task)); LogAssert.Expect(LogType.Log, new Regex(@"\w*Comment found\w*")); }
/// <summary> /// Reusable function to set up the ObjImporter service and to register it at the service manager /// </summary> /// <param name="objContent">The .obj that the fake loader of the obj importer should load</param> /// <param name="mtlContent">The .mtl that the fake loader of the obj importer should load</param> /// <returns></returns> private ObjImporter SetUpObjImporter(string objContent, string mtlContent) { ObjImporter objImporter = new ObjImporter(); IServiceManager serviceManager = A.Fake <IServiceManager>(); objImporter.Initialize(serviceManager); objImporter.ContentLoader = FakeContentLoaderFactory.CreateFakeLoader(objContent); objImporter.MtlLibrary.ContentLoader = FakeContentLoaderFactory.CreateFakeLoader(mtlContent); return(objImporter); }
public IEnumerator LoadLibraryAsync_NewLibrary_LibraryLoadedReturnsTrue() { mtlLibrary.ContentLoader = FakeContentLoaderFactory.CreateFakeLoader(content); Task task = LoadLibrary(); yield return(AsyncTest.WaitForTask(task)); bool loaded = mtlLibrary.LibraryLoaded(libraryName); Assert.IsTrue(loaded, "The library should have been loaded but is not displayed as loaded"); }
public IEnumerator GetMaterialConstructor_ExistentMatLibExistentMat_ReturnsNotNull() { mtlLibrary.ContentLoader = FakeContentLoaderFactory.CreateFakeLoader(content); Task task = LoadLibrary(); yield return(AsyncTest.WaitForTask(task)); MaterialConstructor res = mtlLibrary.GetMaterialConstructor(libraryName, "BlueMat"); Assert.IsNotNull(res); }
public IEnumerator GetMaterialConstructor_ExistentMatLibExistentMat_MatConstrColorSet() { mtlLibrary.ContentLoader = FakeContentLoaderFactory.CreateFakeLoader(content); Task task = LoadLibrary(); yield return(AsyncTest.WaitForTask(task)); MaterialConstructor res = mtlLibrary.GetMaterialConstructor(libraryName, "BlueMat"); Assert.IsNotNull(res); Assert.AreEqual(new Color(0.185991f, 0.249956f, 0.800000f), res.Color); }
public IEnumerator LoadLibraryAsync_LoadFailed_LibraryLoadedReturnsFalse() { mtlLibrary.ContentLoader = FakeContentLoaderFactory.CreateFakeFailLoader <string>(); LogAssert.Expect(LogType.Error, new Regex(@"\w*This is a simulated fail\w*")); Task task = LoadLibrary(); yield return(AsyncTest.WaitForTask(task)); bool loaded = mtlLibrary.LibraryLoaded(libraryName); Assert.IsFalse(loaded, "The import should have aborted but apparently, the library is shown as imported"); }
public IEnumerator FetchTextureAsync_WebRequestFailed_ReturnsNull() { TextureConstructor textureConstructor = new TextureConstructor(loadPath); textureConstructor.TextureLoader = FakeContentLoaderFactory.CreateFakeFailLoader <Texture2D>(); LogAssert.Expect(LogType.Error, new Regex(@"\w*This is a simulated fail\w*")); Task <Texture2D> task = textureConstructor.FetchTextureAsync(); yield return(AsyncTest.WaitForTask(task)); Texture2D res = task.Result; Assert.Null(res); }
public IEnumerator FetchTextureAsync_WebRequestSuccessful_ReturnsTexture() { TextureConstructor textureConstructor = new TextureConstructor(loadPath); Texture2D expected = new Texture2D(2, 2); textureConstructor.TextureLoader = FakeContentLoaderFactory.CreateFakeLoader(expected); Task <Texture2D> task = textureConstructor.FetchTextureAsync(); yield return(AsyncTest.WaitForTask(task)); Texture2D res = task.Result; Assert.NotNull(res); Assert.AreEqual(expected.imageContentsHash, res.imageContentsHash); }
public IEnumerator ImportAsync_WebRequestFailed_ReturnNull() { ObjImporter objImporter = new ObjImporter(); IServiceManager serviceManager = A.Fake <IServiceManager>(); objImporter.Initialize(serviceManager); objImporter.ContentLoader = FakeContentLoaderFactory.CreateFakeFailLoader <string>(); LogAssert.Expect(LogType.Error, new Regex(@"\w*Error fetching obj. No object imported\w*")); Task <GameObject> task = objImporter.ImportAsync("http://test.org/test.obj"); yield return(AsyncTest.WaitForTask(task)); GameObject res = task.Result; Assert.Null(res); }
public IEnumerator LoadLibraryAsync_LoadLibraryMultipleTimes_NoErrorsAndLibraryLoadedTrue() { mtlLibrary.ContentLoader = FakeContentLoaderFactory.CreateFakeLoader(content); Task task = LoadLibrary(); yield return(AsyncTest.WaitForTask(task)); bool loaded = mtlLibrary.LibraryLoaded(libraryName); Assert.IsTrue(loaded, "The library should have been loaded but is not displayed as loaded"); Task task2 = LoadLibrary(); yield return(AsyncTest.WaitForTask(task2)); LogAssert.Expect(LogType.Warning, new Regex(@"\w*was already loaded\w*")); loaded = mtlLibrary.LibraryLoaded(libraryName); Assert.IsTrue(loaded, "Loading the same library multiple times makes the library show up as unloaded"); }
public IEnumerator ImportAsync_ObjFetchSuccessMtlFetchFail_CreateObjectWithDefaultMat() { ObjImporter objImporter = SetUpObjImporter(cubeObj, ""); objImporter.MtlLibrary.ContentLoader = FakeContentLoaderFactory.CreateFakeFailLoader <string>(); LogAssert.Expect(LogType.Error, new Regex(@"\w*This is a simulated fail\w*")); LogAssert.Expect(LogType.Error, new Regex(@"\w*Could not load .mtl file\w*")); Task <GameObject> task = objImporter.ImportAsync("http://test.org/test.obj"); yield return(AsyncTest.WaitForTask(task)); GameObject res = task.Result; Assert.NotNull(res); Assert.AreEqual(1, res.transform.childCount); MeshRenderer mr = res.transform.GetChild(0).GetComponent <MeshRenderer>(); Assert.AreEqual("New Material", mr.sharedMaterial.name); }