LoadMeshTests.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using NUnit.Framework;
  6. namespace SharpGLTF.Geometry
  7. {
  8. [TestFixture]
  9. public class LoadMeshTests
  10. {
  11. #region setup
  12. [OneTimeSetUp]
  13. public void Setup()
  14. {
  15. TestFiles.CheckoutDataDirectories();
  16. }
  17. #endregion
  18. [Test]
  19. public void LoadModels()
  20. {
  21. foreach (var f in TestFiles.GetSampleFilePaths())
  22. {
  23. var root = GltfUtils.LoadModel(f);
  24. Assert.NotNull(root);
  25. }
  26. }
  27. [Test]
  28. public void LoadBrokenFile()
  29. {
  30. var f = TestFiles.GetSampleFilePaths().First(item => item.EndsWith(".gltf"));
  31. var json = System.IO.File.ReadAllText(f);
  32. // break the file
  33. json = json.Substring(0, json.Length - 40);
  34. Assert.Throws<Newtonsoft.Json.JsonReaderException>(() => Schema2.ModelRoot.ParseGLTF(json, new Schema2.ReadSettings()));
  35. }
  36. }
  37. }