GenericTests.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using NUnit.Framework;
  2. using SharpGLTF.Schema2;
  3. using SharpGLTF.Validation;
  4. using System;
  5. namespace SharpGLTF
  6. {
  7. [Category("Toolkit.Scenes")]
  8. public class ExtStructuralMetadataTests
  9. {
  10. [SetUp]
  11. public void SetUp()
  12. {
  13. Tiles3DExtensions.RegisterExtensions();
  14. }
  15. // Test files are from https://github.com/CesiumGS/3d-tiles-validator/tree/main/specs/data/gltfExtensions/
  16. [Test(Description = "Reads generic 3D Tiles glTF's")]
  17. [TestCase("FeatureIdAttributeAndPropertyTableFeatureIdNotInRange.gltf", typeof(ModelException))]
  18. [TestCase("FeatureIdAttributePropertyTableInvalidValue.gltf", typeof(ModelException))]
  19. [TestCase("FeatureIdAttributePropertyTableWithoutPropertyTables.gltf", typeof(ModelException))]
  20. [TestCase("FeatureIdAttributePropertyTableWithoutStructuralMetadata.gltf", typeof(ModelException))]
  21. [TestCase("FeatureIdTextureAndPropertyTableFeatureIdNotInRange.gltf", typeof(ModelException))]
  22. [TestCase("ValidFeatureIdAttributeAndPropertyTable.gltf", null)]
  23. [TestCase("ValidFeatureIdTextureAndPropertyTable.gltf", null)]
  24. public void ReadGenericFiles(string file, Type exception = null)
  25. {
  26. var fileName = ResourceInfo.From(file);
  27. if (exception != null)
  28. {
  29. Assert.Throws(exception, delegate { ModelRoot.Load(fileName); });
  30. }
  31. else
  32. {
  33. var model = ModelRoot.Load(fileName);
  34. var ctx = new ValidationResult(model, ValidationMode.Strict, true);
  35. model.ValidateContent(ctx.GetContext());
  36. }
  37. }
  38. }
  39. }