GenericTests.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using NUnit.Framework;
  2. using SharpGLTF.Schema2;
  3. using SharpGLTF.Validation;
  4. using System;
  5. using System.IO;
  6. namespace SharpGLTF
  7. {
  8. [Category("Toolkit.Scenes")]
  9. public class ExtStructuralMetadataTests
  10. {
  11. [SetUp]
  12. public void SetUp()
  13. {
  14. Tiles3DExtensions.RegisterExtensions();
  15. var fileName = ResourceInfo.From("_");
  16. TestContext.WriteLine("Dumping current Resource context:");
  17. foreach(var f in fileName.File.Directory.EnumerateDirectories("*",System.IO.SearchOption.AllDirectories))
  18. {
  19. TestContext.WriteLine($"{f.Exists} {f.FullName}");
  20. }
  21. foreach (var f in fileName.File.Directory.EnumerateFiles("*", System.IO.SearchOption.AllDirectories))
  22. {
  23. TestContext.WriteLine($"{f.Exists} {f.FullName}");
  24. }
  25. }
  26. // Test files are from https://github.com/CesiumGS/3d-tiles-validator/tree/main/specs/data/gltfExtensions/
  27. [Test(Description = "Reads generic 3D Tiles glTF's")]
  28. [TestCase("FeatureIdAttributeAndPropertyTableFeatureIdNotInRange.gltf", typeof(ModelException))]
  29. [TestCase("FeatureIdAttributePropertyTableInvalidValue.gltf", typeof(ModelException))]
  30. [TestCase("FeatureIdAttributePropertyTableWithoutPropertyTables.gltf", typeof(ModelException))]
  31. [TestCase("FeatureIdAttributePropertyTableWithoutStructuralMetadata.gltf", typeof(ModelException))]
  32. [TestCase("FeatureIdTextureAndPropertyTableFeatureIdNotInRange.gltf", typeof(ModelException))]
  33. [TestCase("ValidFeatureIdAttributeAndPropertyTable.gltf", null)]
  34. [TestCase("ValidFeatureIdTextureAndPropertyTable.gltf", null)]
  35. public void ReadGenericFiles(string file, Type exception = null)
  36. {
  37. var fileName = ResourceInfo.From(file);
  38. if (exception != null)
  39. {
  40. Assert.Throws(exception, delegate { ModelRoot.Load(fileName); });
  41. }
  42. else
  43. {
  44. var model = ModelRoot.Load(fileName);
  45. var ctx = new ValidationResult(model, ValidationMode.Strict, true);
  46. model.ValidateContent(ctx.GetContext());
  47. }
  48. }
  49. }
  50. }