public void LoadNegativeModels() { TestContext.CurrentContext.AttachShowDirLink(); var files = TestFiles.GetReferenceModelPaths(true); bool passed = true; foreach (var f in files) { try { var model = ModelRoot.Load(f.Item1); if (!f.Item2) { TestContext.Error.WriteLine($"{f.Item1.ToShortDisplayPath()} 👎😦 Should not load!"); passed = false; } else { TestContext.WriteLine($"{f.Item1.ToShortDisplayPath()} 🙂👍"); } } catch (Exception ex) { if (f.Item2) { TestContext.Error.WriteLine($"{f.Item1.ToShortDisplayPath()} 👎😦 Should load!"); TestContext.Error.WriteLine($" ERROR: {ex.Message}"); passed = false; } else { TestContext.WriteLine($"{f.Item1.ToShortDisplayPath()} 🙂👍"); TestContext.WriteLine($" Exception: {ex.Message}"); } } if (f.Item2 && !f.Item1.ToLower().Contains("compatibility")) { var model = ModelRoot.Load(f.Item1); model.AttachToCurrentTest(System.IO.Path.ChangeExtension(System.IO.Path.GetFileName(f.Item1), ".obj")); } } Assert.IsTrue(passed); }
public void TestLoadReferenceModels() { TestContext.CurrentContext.AttachShowDirLink(); var files = TestFiles.GetReferenceModelPaths(); foreach (var f in files) { // var errors = _LoadNumErrorsForModel(f); // if (errors > 0) continue; try { var model = ModelRoot.Load(f); model.AttachToCurrentTest(System.IO.Path.ChangeExtension(System.IO.Path.GetFileName(f), ".obj")); } catch (IO.UnsupportedExtensionException eex) { TestContext.WriteLine($"{f.ToShortDisplayPath()} ERROR: {eex.Message}"); } } }
public void LoadGeneratedModels(bool isNegativeCase) { TestContext.CurrentContext.AttachShowDirLink(); var files = TestFiles.GetReferenceModelPaths(isNegativeCase); bool passed = true; foreach (var filePath in files) { // System.Diagnostics.Debug.Assert(!filePath.EndsWith("Compatibility_05.gltf")); var gltfJson = filePath.EndsWith(".gltf") ? System.IO.File.ReadAllText(filePath) : string.Empty; var report = gltf_validator.ValidateFile(filePath); if (report == null) { continue; // ?? } if (report.Warnings.Any(item => item.Contains("Cannot validate an extension"))) { continue; } try { var model = ModelRoot.Load(filePath); if (report.HasErrors) { TestContext.Error.WriteLine($"{filePath.ToShortDisplayPath()} 👎😦 Should not load!"); passed = false; } else { TestContext.WriteLine($"{filePath.ToShortDisplayPath()} 🙂👍"); } } catch (Exception ex) { if (!report.HasErrors) { TestContext.Error.WriteLine($"{filePath.ToShortDisplayPath()} 👎😦 Should load!"); TestContext.Error.WriteLine($" ERROR: {ex.Message}"); passed = false; } else { TestContext.WriteLine($"{filePath.ToShortDisplayPath()} 🙂👍"); TestContext.WriteLine($" Exception: {ex.Message}"); } } /* * if (ShouldLoad && !filePath.ToLower().Contains("compatibility")) * { * var model = ModelRoot.Load(filePath); * model.AttachToCurrentTest(System.IO.Path.ChangeExtension(System.IO.Path.GetFileName(filePath), ".obj")); * }*/ } Assert.IsTrue(passed); }
public void LoadGeneratedModels(bool isNegativeCase) { var files = TestFiles.GetReferenceModelPaths(isNegativeCase); bool passed = true; foreach (var filePath in files) { // System.Diagnostics.Debug.Assert(!filePath.EndsWith("Buffer_Interleaved_03.gltf")); if (filePath.EndsWith("Compatibility_05.gltf")) { continue; // contains a REQUIRED Material_QuantumRendering } var gltfJson = filePath.EndsWith(".gltf") ? System.IO.File.ReadAllText(filePath) : string.Empty; var report = GltfValidator.ValidationReport.Validate(filePath); if (report == null) { continue; // ?? } if (report.HasUnsupportedExtensions) { continue; } try { var model = ModelRoot.Load(filePath); if (report.Severity == GltfValidator.Severity.Error) { TestContext.Error.WriteLine($"{filePath.ToShortDisplayPath()} 👎😦 Should not load!"); passed = false; } else { TestContext.WriteLine($"{filePath.ToShortDisplayPath()} 🙂👍"); } } catch (Exception ex) { if (report.Severity != GltfValidator.Severity.Error) { TestContext.Error.WriteLine($"{filePath.ToShortDisplayPath()} 👎😦 Should load!"); TestContext.Error.WriteLine($" ERROR: {ex.Message}"); passed = false; } else { TestContext.WriteLine($"{filePath.ToShortDisplayPath()} 🙂👍"); TestContext.WriteLine($" Expected Exception: {ex.Message}"); } } /* * if (ShouldLoad && !filePath.ToLowerInvariant().Contains("compatibility")) * { * var model = ModelRoot.Load(filePath); * model.AttachToCurrentTest(System.IO.Path.ChangeExtension(System.IO.Path.GetFileName(filePath), ".obj")); * }*/ } Assert.IsTrue(passed); }