// *********************************************************************** // Copyright (c) 2017 Unity Technologies. All rights reserved. // // Licensed under the ##LICENSENAME##. // See LICENSE.md file in the project root for full license information. // *********************************************************************** using NUnit.Framework; using Autodesk.Fbx; namespace Autodesk.Fbx.UnitTests { /// /// Run some tests that any vector type should be able to pass. /// If you add tests here, you probably want to add them to the other /// FbxDouble* test classes. /// public class FbxSystemUnitTest : TestBase { [Test] public void TestEquality() { EqualityTester.TestEquality(FbxSystemUnit.mm, FbxSystemUnit.Yard, new FbxSystemUnit(0.1)); } /// /// Test the basics. Subclasses should override and add some calls /// e.g. to excercise all the constructors. /// [Test] public void TestBasics() { // Call all the functions. Test that a few of them actually work // (rather than merely not crashing). using (FbxSystemUnit.mm) { } using (FbxSystemUnit.cm) { } using (FbxSystemUnit.dm) { } using (FbxSystemUnit.m) { } using (FbxSystemUnit.km) { } using (FbxSystemUnit.Inch) { } using (FbxSystemUnit.Foot) { } using (FbxSystemUnit.Yard) { } var units = new FbxSystemUnit(0.1); Assert.AreEqual(0.1, units.GetScaleFactor()); Assert.AreEqual(1, units.GetMultiplier(), 1); Assert.AreEqual("mm", units.GetScaleFactorAsString()); Assert.AreEqual(FbxSystemUnit.mm, units); Assert.AreNotEqual(FbxSystemUnit.km, units); units.GetHashCode(); units.ToString(); units.Dispose(); units = new FbxSystemUnit(0.1378123891, 324823); units.ToString(); Assert.AreEqual("custom unit", units.GetScaleFactorAsString(pAbbreviated: false)); Assert.AreNotEqual(units, FbxSystemUnit.mm); // test GetGetConversionFactor Assert.AreEqual(FbxSystemUnit.cm.GetConversionFactorTo(FbxSystemUnit.Foot), FbxSystemUnit.Foot.GetConversionFactorFrom(FbxSystemUnit.cm)); // test ConversionOptions.Dispose() FbxSystemUnit.ConversionOptions options = new FbxSystemUnit.ConversionOptions(); options.Dispose (); using (var manager = FbxManager.Create ()) { FbxScene scene = FbxScene.Create (manager, "scene"); // test ConvertScene (make sure it doesn't crash) FbxSystemUnit.cm.ConvertScene (scene); FbxSystemUnit.m.ConvertScene(scene, new FbxSystemUnit.ConversionOptions()); // test null Assert.That (() => { FbxSystemUnit.dm.ConvertScene(null); }, Throws.Exception.TypeOf()); // test destroyed scene.Destroy(); Assert.That (() => { FbxSystemUnit.dm.ConvertScene(scene); }, Throws.Exception.TypeOf()); } } } }