using System.Diagnostics; using Microsoft.Extensions.FileSystemGlobbing; using Microsoft.Extensions.FileSystemGlobbing.Abstractions; namespace ReFuel.Gltf.Tests; [TestClass] public sealed class ParseCompliantDocuments { public static string DocumentsDirectory { get; } = "../../../assets/gltf-research-scenes/scenes"; public static string CoreDocumentGlob { get; } = "**/gltf/*_core.gltf"; public static string ExtendedDocumentGlob { get; } = "**/gltf/*_extended.gltf"; public static IEnumerable FetchTestDocuments(string glob) { Matcher matcher = new Matcher(); matcher.AddInclude(glob); PatternMatchingResult result = matcher.Execute(new DirectoryInfoWrapper(new DirectoryInfo(DocumentsDirectory))); return result.Files.Select(x => new GltfTestDocument(new FileInfo(Path.Combine(DocumentsDirectory, x.Path)))); } public static IEnumerable Documents => FetchTestDocuments(ExtendedDocumentGlob); // [TestMethod] // [TestCategory("Core")] // [DynamicData(nameof(CoreDocuments))] // public void ParseCoreDocuments(GltfTestDocument doc) // { // doc.Parse().Dispose(); // } [TestMethod] [DynamicData(nameof(Documents))] public void ParseDocuments(GltfTestDocument doc) { doc.Parse().Dispose(); } [TestMethod] [DynamicData(nameof(Documents))] public void AssertExtensionCount(GltfTestDocument doc) { GltfDocument gltf = doc.Parse(); if (!doc.LoadValidationDocument()) Assert.Inconclusive(); Assert.HasCount(doc.ValidationDocument.Outputs.ExtendedExtensions.Count, gltf.Extensions); } [TestMethod] [DynamicData(nameof(Documents))] public void AssertMaterialCount(GltfTestDocument doc) { GltfDocument gltf = doc.Parse(); if (!doc.LoadValidationDocument()) Assert.Inconclusive(); Assert.HasCount(doc.ValidationDocument.Summary.Materials, gltf.Materials); } [TestMethod] [DynamicData(nameof(Documents))] public void AssertTexturesCount(GltfTestDocument doc) { GltfDocument gltf = doc.Parse(); if (!doc.LoadValidationDocument()) Assert.Inconclusive(); Assert.HasCount(doc.ValidationDocument.Summary.Textures, gltf.Images); } }