FbxManagerTest.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // ***********************************************************************
  2. // Copyright (c) 2017 Unity Technologies. All rights reserved.
  3. //
  4. // Licensed under the ##LICENSENAME##.
  5. // See LICENSE.md file in the project root for full license information.
  6. // ***********************************************************************
  7. using NUnit.Framework;
  8. using Autodesk.Fbx;
  9. namespace Autodesk.Fbx.UnitTests
  10. {
  11. public class FbxManagerTest
  12. {
  13. FbxManager m_fbxManager;
  14. [SetUp]
  15. public void Init ()
  16. {
  17. m_fbxManager = FbxManager.Create ();
  18. }
  19. [TearDown]
  20. public void End ()
  21. {
  22. m_fbxManager.Destroy ();
  23. }
  24. [Test]
  25. public void TestVersion ()
  26. {
  27. string version = FbxManager.GetVersion ();
  28. Assert.IsNotEmpty (version);
  29. string versionLong = FbxManager.GetVersion (true);
  30. Assert.IsNotEmpty (versionLong);
  31. string versionShort = FbxManager.GetVersion (false);
  32. Assert.IsNotEmpty (versionShort);
  33. }
  34. [Test]
  35. public void TestGetFileFormatVersion ()
  36. {
  37. int major = -1, minor = -1, revision = -1;
  38. FbxManager.GetFileFormatVersion (out major, out minor, out revision);
  39. Assert.GreaterOrEqual (major, 0);
  40. Assert.GreaterOrEqual (minor, 0);
  41. Assert.GreaterOrEqual (revision, 0);
  42. }
  43. [Test]
  44. public void TestIOSettings ()
  45. {
  46. FbxIOSettings ioSettings = m_fbxManager.GetIOSettings ();
  47. Assert.IsNull(ioSettings);
  48. using (FbxIOSettings ioSettings1 = FbxIOSettings.Create (m_fbxManager, "")) {
  49. m_fbxManager.SetIOSettings (ioSettings1);
  50. FbxIOSettings ioSettings2 = m_fbxManager.GetIOSettings ();
  51. Assert.IsNotNull (ioSettings2);
  52. }
  53. }
  54. [Test]
  55. public void TestIdentity ()
  56. {
  57. using (FbxObject obj = FbxObject.Create (m_fbxManager, "")) {
  58. FbxManager fbxManager2 = obj.GetFbxManager();
  59. Assert.AreEqual (m_fbxManager, fbxManager2);
  60. }
  61. }
  62. [Test]
  63. public void TestUsing ()
  64. {
  65. // Test that the using statement works, and destroys the manager.
  66. FbxObject obj;
  67. using (var mgr = FbxManager.Create ()) {
  68. obj = FbxObject.Create(mgr, "asdf");
  69. }
  70. Assert.That(() => { obj.GetName (); }, Throws.Exception.TypeOf<System.ArgumentNullException>());
  71. // Also test explicit dispose.
  72. var mgr2 = FbxManager.Create();
  73. obj = FbxObject.Create(mgr2, "hjkl");
  74. mgr2.Dispose();
  75. Assert.That(() => { obj.GetName (); }, Throws.Exception.TypeOf<System.ArgumentNullException>());
  76. }
  77. [Test]
  78. public void TestGetIOPluginRegistry()
  79. {
  80. // pretty much just want to check that it doesn't crash
  81. var ioPluginRegistry = m_fbxManager.GetIOPluginRegistry();
  82. Assert.IsInstanceOf<FbxIOPluginRegistry> (ioPluginRegistry);
  83. }
  84. #if ENABLE_COVERAGE_TEST
  85. [Test]
  86. public void TestCoverage() { CoverageTester.TestCoverage(typeof(FbxManager), this.GetType()); }
  87. #endif
  88. }
  89. }