FbxLimitsTest.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // ***********************************************************************
  2. // Copyright (c) 2018 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 System.Collections;
  9. using Autodesk.Fbx;
  10. namespace Autodesk.Fbx.UnitTests
  11. {
  12. public class FbxLimitsTest : TestBase<FbxLimits>
  13. {
  14. // There's lots of flags with get/set to test. Do it with lambdas.
  15. delegate bool GetActive();
  16. delegate void SetActive(bool active);
  17. void AssertActiveFlag(GetActive getActive, SetActive setActive)
  18. {
  19. Assert.IsFalse(getActive());
  20. setActive(true);
  21. Assert.IsTrue(getActive());
  22. }
  23. [Test]
  24. public void TestBasics ()
  25. {
  26. var limits = new FbxLimits();
  27. AssertActiveFlag(limits.GetActive, limits.SetActive);
  28. AssertActiveFlag(limits.GetMinXActive, limits.SetMinXActive);
  29. AssertActiveFlag(limits.GetMinYActive, limits.SetMinYActive);
  30. AssertActiveFlag(limits.GetMinZActive, limits.SetMinZActive);
  31. limits.SetMin(new FbxDouble3(1, 2, 3));
  32. Assert.That(limits.GetMin(), Is.EqualTo(new FbxDouble3(1, 2, 3)));
  33. AssertActiveFlag(limits.GetMaxXActive, limits.SetMaxXActive);
  34. AssertActiveFlag(limits.GetMaxYActive, limits.SetMaxYActive);
  35. AssertActiveFlag(limits.GetMaxZActive, limits.SetMaxZActive);
  36. limits.SetMax(new FbxDouble3(4, 5, 6));
  37. Assert.That(limits.GetMax(), Is.EqualTo(new FbxDouble3(4, 5, 6)));
  38. Assert.That(limits.Apply(new FbxDouble3(7, 8, 9)), Is.EqualTo(new FbxDouble3(4, 5, 6)));
  39. limits.SetMinActive(false, true, false);
  40. Assert.IsFalse(limits.GetMinXActive());
  41. Assert.IsTrue(limits.GetMinYActive());
  42. limits.SetMaxActive(false, false, false);
  43. Assert.IsFalse(limits.GetMaxXActive());
  44. Assert.IsTrue(limits.GetAnyMinMaxActive());
  45. limits.Dispose();
  46. }
  47. }
  48. }