FbxBindingTableTest.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. using System.Collections.Generic;
  10. namespace Autodesk.Fbx.UnitTests
  11. {
  12. public class FbxBindingTableTest : Base<FbxBindingTable>
  13. {
  14. #if ENABLE_COVERAGE_TEST
  15. [Test]
  16. public override void TestCoverage() {
  17. // This test is also responsible for FbxBindingTableBase and FbxBindingTableEntry
  18. base.TestCoverage();
  19. CoverageTester.TestCoverage(typeof(FbxBindingTableBase), this.GetType());
  20. CoverageTester.TestCoverage(typeof(FbxBindingTableEntry), this.GetType());
  21. CoverageTester.TestCoverage(typeof(FbxEntryView), this.GetType());
  22. CoverageTester.TestCoverage(typeof(FbxPropertyEntryView), this.GetType());
  23. CoverageTester.TestCoverage(typeof(FbxSemanticEntryView), this.GetType());
  24. }
  25. #endif
  26. [Test]
  27. public void TestBasics() {
  28. var table = FbxBindingTable.Create(Manager, "table");
  29. // Call the getters, make sure they get.
  30. GetSetProperty(table.DescAbsoluteURL, "file:///dev/null");
  31. GetSetProperty(table.DescRelativeURL, "shader.glsl");
  32. GetSetProperty(table.DescTAG, "user");
  33. // Test dispose.
  34. var entry = table.AddNewEntry();
  35. DisposeTester.TestDispose(entry);
  36. // Test the views.
  37. entry = table.AddNewEntry();
  38. var propertyView = new FbxPropertyEntryView(entry, false);
  39. Assert.IsFalse(propertyView.IsValid());
  40. DisposeTester.TestDispose(propertyView);
  41. propertyView = new FbxPropertyEntryView(entry, true, true);
  42. Assert.IsTrue(propertyView.IsValid());
  43. Assert.AreEqual("FbxPropertyEntry", propertyView.EntryType());
  44. propertyView.SetProperty("property");
  45. Assert.AreEqual("property", propertyView.GetProperty());
  46. var semanticView = new FbxSemanticEntryView(entry, false);
  47. Assert.IsFalse(semanticView.IsValid());
  48. DisposeTester.TestDispose(semanticView);
  49. semanticView = new FbxSemanticEntryView(entry, false, true);
  50. Assert.IsTrue(semanticView.IsValid());
  51. Assert.AreEqual("FbxSemanticEntry", semanticView.EntryType());
  52. semanticView.SetSemantic("semantic");
  53. Assert.AreEqual("semantic", semanticView.GetSemantic());
  54. Assert.AreEqual(0, semanticView.GetIndex());
  55. Assert.AreEqual("semantic", semanticView.GetSemantic(false));
  56. }
  57. void GetSetProperty(FbxPropertyString prop, string value) {
  58. prop.Set(value);
  59. Assert.AreEqual(value, prop.Get());
  60. }
  61. }
  62. }