Skip to content

Commit 56b8fa1

Browse files
author
DESKTOP-F8VO8FK\Austin
committed
[ADDED] a comparer to compare keyframes
1 parent ebd74e9 commit 56b8fa1

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

Assets/FbxExporters/Editor/UnitTests/FbxCameraTests.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
using UnityEngine;
22
using UnityEditor;
33
using NUnit.Framework;
4+
using System.Collections.Generic;
45

56
namespace FbxExporters.UnitTests
67
{
8+
public class MyKeyComparer : IComparer<Keyframe>
9+
{
10+
public int Compare(Keyframe a, Keyframe b)
11+
{
12+
Debug.Log(string.Format("a.value: {0}, b.value: {1}, a.time: {2}, b.time: {3}", a.value, b.value, a.time, b.time));
13+
return a.time == b.time && a.value == b.value ? 0 : 1;
14+
}
15+
}
16+
717
public class FbxCameraTest : ExporterTestBase
818
{
919

@@ -15,6 +25,7 @@ public void AnimationWithCameraFOVTest()
1525
go.name = "originalCamera";
1626
Camera camera = go.AddComponent(typeof(Camera)) as Camera;
1727
Animation anim = go.AddComponent(typeof(Animation)) as Animation;
28+
1829
Keyframe[] keys = new Keyframe[3];
1930
keys[0] = new Keyframe(0.0f, 1f);
2031
keys[1] = new Keyframe(1.0f, 2f);
@@ -64,11 +75,8 @@ public void AnimationWithCameraFOVTest()
6475

6576
Assert.That(exportedCurve.keys.Length, Is.EqualTo(keys.Length));
6677

67-
for (int i = 0; i < exportedCurve.keys.Length; i++)
68-
{
69-
Assert.That(exportedCurve.keys[i].time == keys[i].time);
70-
Assert.That(exportedCurve.keys[i].value == keys[i].value);
71-
}
78+
//check imported animation against original
79+
Assert.That(exportedCurve.keys, Is.EqualTo(keys).Using<Keyframe>(new MyKeyComparer()), string.Format("key doesn't match"));
7280
}
7381

7482
}

0 commit comments

Comments
 (0)