BindOnScheduleTest.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using NUnit.Framework;
  2. using UnityEngine;
  3. namespace LitMotion.Tests.Runtime
  4. {
  5. public class BindOnScheduleTest
  6. {
  7. [Test]
  8. public void Test_BindOnSchedule()
  9. {
  10. var value = 0f;
  11. var motion = LMotion.Create(1f, 0f, 1f)
  12. .Bind(x => value = x);
  13. motion.Cancel();
  14. Assert.That(value, Is.EqualTo(0f));
  15. value = 0f;
  16. motion = LMotion.Create(1f, 0f, 1f)
  17. .WithBindOnSchedule()
  18. .Bind(x => value = x);
  19. motion.Cancel();
  20. Assert.That(value, Is.EqualTo(1f));
  21. }
  22. [Test]
  23. public void Test_BindOnSchedule_AnimationCurve()
  24. {
  25. var curve = AnimationCurve.EaseInOut(0f, 1f, 1f, 0f);
  26. var value = 0f;
  27. var motion = LMotion.Create(0f, 1f, 1f)
  28. .WithEase(curve)
  29. .WithBindOnSchedule()
  30. .Bind(x => value = x);
  31. motion.Cancel();
  32. Assert.That(value, Is.EqualTo(1f));
  33. }
  34. }
  35. }