Bez popisu
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.

ThermalStateTrackerUnitTests.cs 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #if NUGET_MOQ_AVAILABLE
  2. using System;
  3. using Moq;
  4. using NUnit.Framework;
  5. using UnityEngine;
  6. using UnityEngine.AdaptivePerformance;
  7. namespace UnityEditor.AdaptivePerformance.Editor.Tests
  8. {
  9. public class ThermalStateTrackerUnitTests
  10. {
  11. IAdaptivePerformance apStub;
  12. IThermalStatus thermalStatusStub;
  13. ThermalMetrics tmStub;
  14. [SetUp]
  15. public void Initialize()
  16. {
  17. apStub = Mock.Of<IAdaptivePerformance>();
  18. thermalStatusStub = Mock.Of<IThermalStatus>();
  19. tmStub = new ThermalMetrics();
  20. Mock.Get(apStub).Setup(h => h.ThermalStatus).Returns(thermalStatusStub);
  21. Holder.Instance = apStub;
  22. }
  23. [TestCase(StateAction.Increase, WarningLevel.NoWarning, 0f, 0f)]
  24. [TestCase(StateAction.FastDecrease, WarningLevel.Throttling,0f, 0f)]
  25. [TestCase(StateAction.Stale, WarningLevel.ThrottlingImminent,0f, 0f)]
  26. [TestCase(StateAction.FastDecrease, WarningLevel.ThrottlingImminent,0f, 0.6f)]
  27. [TestCase(StateAction.Decrease, WarningLevel.ThrottlingImminent,0f, 0.27f)]
  28. [TestCase(StateAction.Increase, WarningLevel.NoWarning, 0.8f, -0.4f)]
  29. [TestCase(StateAction.FastDecrease, WarningLevel.NoWarning, 0.8f, 0.67f)]
  30. [TestCase(StateAction.Decrease, WarningLevel.NoWarning, 0.8f, 0.28f)]
  31. public void VerifyStateAction_With_VaryingWarningLevelsUponUpdate(StateAction stateAction, WarningLevel warningLevel, float tempL, float trend)
  32. {
  33. tmStub = SetupThermalMetricsInstance(warningLevel, tempL, trend);
  34. Mock.Get(thermalStatusStub).Setup(t => t.ThermalMetrics).Returns(tmStub);
  35. Assert.AreEqual(stateAction, new ThermalStateTracker().Update());
  36. }
  37. ThermalMetrics SetupThermalMetricsInstance(WarningLevel wl, float tempLevel, float tempTrend)
  38. {
  39. tmStub.WarningLevel = wl;
  40. tmStub.TemperatureLevel = tempLevel;
  41. tmStub.TemperatureTrend = tempTrend;
  42. return tmStub;
  43. }
  44. }
  45. }
  46. #endif