No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AdaptivePerformanceScalerEfficiencyTrackerUnitTests.cs 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #if NUGET_MOQ_AVAILABLE
  2. using System;
  3. using Moq;
  4. using NUnit.Framework;
  5. using UnityEngine;
  6. using UnityEngine.AdaptivePerformance;
  7. using UnityEngine.AdaptivePerformance.Provider;
  8. using FrameTiming = UnityEngine.AdaptivePerformance.FrameTiming;
  9. namespace UnityEditor.AdaptivePerformance.Editor.Tests
  10. {
  11. public class AdaptivePerformanceScalerEfficiencyTrackerUnitTests
  12. {
  13. FrameTiming ft;
  14. IAdaptivePerformance m_ap;
  15. IPerformanceStatus m_perfStat;
  16. AdaptivePerformanceScaler m_perfScaler;
  17. AdaptivePerformanceScalerEfficiencyTracker testSubject;
  18. [SetUp]
  19. public void startFixture()
  20. {
  21. ft = new FrameTiming();
  22. m_ap = Mock.Of<IAdaptivePerformance>();
  23. m_perfStat = Mock.Of<IPerformanceStatus>();
  24. m_perfScaler = Mock.Of<AdaptivePerformanceScaler>();
  25. Mock.Get(m_perfStat).Setup(s => s.FrameTiming).Returns(ft);
  26. Mock.Get(m_ap).Setup(p => p.PerformanceStatus).Returns(m_perfStat);
  27. Holder.Instance = m_ap;
  28. testSubject = new AdaptivePerformanceScalerEfficiencyTracker();
  29. }
  30. [Test]
  31. public void ScalarNotRunning_WhenTracker_NeitherStarted_OrStopped()
  32. {
  33. Assert.AreEqual(false, testSubject.IsRunning);
  34. }
  35. [Test]
  36. public void ScalarNotRunning_WhenStarted_ButProvidedScalerNotInitialized()
  37. {
  38. testSubject.Start(null, false);
  39. Assert.AreEqual(false, testSubject.IsRunning);
  40. }
  41. [Test]
  42. public void ScalarRunning_WhenStarted_ProvidedScalerInitialized()
  43. {
  44. testSubject.Start(m_perfScaler, false);
  45. Assert.AreEqual(true, testSubject.IsRunning);
  46. }
  47. [Test]
  48. public void ScalarNotRunning_WhenStartedThenStopped_ProvidedScalerInitialized()
  49. {
  50. testSubject.Start(m_perfScaler, false);
  51. testSubject.Stop();
  52. Assert.AreEqual(false, testSubject.IsRunning);
  53. }
  54. [Test]
  55. public void ScalarNotRunning_WhenonlyStopped()
  56. {
  57. Assert.Throws<NullReferenceException>(StoppingScalarWithoutRunning);
  58. }
  59. void StoppingScalarWithoutRunning()
  60. {
  61. testSubject.Stop();
  62. }
  63. }
  64. }
  65. #endif