/ GUNRPG.Tests / PetConstantsTests.cs
PetConstantsTests.cs
1 using GUNRPG.Core.VirtualPet; 2 using Xunit; 3 4 namespace GUNRPG.Tests; 5 6 public class PetConstantsTests 7 { 8 [Fact] 9 public void PetConstants_StatBoundaries_AreCorrectlyDefined() 10 { 11 // Assert 12 Assert.Equal(100f, PetConstants.MaxStatValue); 13 Assert.Equal(0f, PetConstants.MinStatValue); 14 Assert.True(PetConstants.MaxStatValue > PetConstants.MinStatValue); 15 } 16 17 [Fact] 18 public void PetConstants_BackgroundDecayRates_ArePositive() 19 { 20 // Assert - All decay rates should be positive 21 Assert.True(PetConstants.HungerIncreasePerHour > 0f); 22 Assert.True(PetConstants.HydrationDecreasePerHour > 0f); 23 Assert.True(PetConstants.FatigueIncreasePerHour > 0f); 24 Assert.True(PetConstants.StressIncreasePerHour > 0f); 25 } 26 27 [Fact] 28 public void PetConstants_RecoveryRates_ArePositive() 29 { 30 // Assert - All recovery rates should be positive 31 Assert.True(PetConstants.HealthRecoveryPerHour > 0f); 32 Assert.True(PetConstants.StressRecoveryPerHour > 0f); 33 Assert.True(PetConstants.FatigueRecoveryPerHour > 0f); 34 } 35 36 [Fact] 37 public void PetConstants_HungerIncreasePerHour_HasReasonableValue() 38 { 39 // Assert - Should be reasonable for gameplay (not too fast or slow) 40 Assert.InRange(PetConstants.HungerIncreasePerHour, 1f, 20f); 41 } 42 43 [Fact] 44 public void PetConstants_HydrationDecreasePerHour_HasReasonableValue() 45 { 46 // Assert - Should be reasonable for gameplay (not too fast or slow) 47 Assert.InRange(PetConstants.HydrationDecreasePerHour, 1f, 20f); 48 } 49 50 [Fact] 51 public void PetConstants_FatigueIncreasePerHour_HasReasonableValue() 52 { 53 // Assert - Should be reasonable for gameplay (not too fast or slow) 54 Assert.InRange(PetConstants.FatigueIncreasePerHour, 1f, 30f); 55 } 56 57 [Fact] 58 public void PetConstants_StressIncreasePerHour_HasReasonableValue() 59 { 60 // Assert - Should be reasonable for gameplay (not too fast or slow) 61 Assert.InRange(PetConstants.StressIncreasePerHour, 1f, 20f); 62 } 63 64 [Fact] 65 public void PetConstants_HealthRecoveryPerHour_HasReasonableValue() 66 { 67 // Assert - Should be reasonable for gameplay (not too fast or slow) 68 Assert.InRange(PetConstants.HealthRecoveryPerHour, 5f, 50f); 69 } 70 71 [Fact] 72 public void PetConstants_StressRecoveryPerHour_HasReasonableValue() 73 { 74 // Assert - Should be reasonable for gameplay (not too fast or slow) 75 Assert.InRange(PetConstants.StressRecoveryPerHour, 5f, 50f); 76 } 77 78 [Fact] 79 public void PetConstants_FatigueRecoveryPerHour_HasReasonableValue() 80 { 81 // Assert - Should be reasonable for gameplay (not too fast or slow) 82 Assert.InRange(PetConstants.FatigueRecoveryPerHour, 5f, 50f); 83 } 84 85 [Fact] 86 public void PetConstants_DecayAndRecoveryRates_AreBalanced() 87 { 88 // Assert - Recovery rates should generally be higher than decay rates 89 // to allow for meaningful rest periods 90 Assert.True(PetConstants.FatigueRecoveryPerHour > PetConstants.FatigueIncreasePerHour, 91 "Fatigue recovery should be faster than fatigue increase for balanced gameplay"); 92 93 Assert.True(PetConstants.StressRecoveryPerHour > PetConstants.StressIncreasePerHour, 94 "Stress recovery should be faster than stress increase for balanced gameplay"); 95 } 96 97 [Fact] 98 public void PetConstants_CanCalculateTimeToMaxStat() 99 { 100 // Arrange - Calculate how long it takes to reach max from min 101 float hoursToMaxHunger = (PetConstants.MaxStatValue - PetConstants.MinStatValue) 102 / PetConstants.HungerIncreasePerHour; 103 104 float hoursToDepletedHydration = (PetConstants.MaxStatValue - PetConstants.MinStatValue) 105 / PetConstants.HydrationDecreasePerHour; 106 107 // Assert - Should take a reasonable amount of time (not instant, not forever) 108 Assert.InRange(hoursToMaxHunger, 1f, 100f); 109 Assert.InRange(hoursToDepletedHydration, 1f, 100f); 110 } 111 112 [Fact] 113 public void PetConstants_CanCalculateRecoveryTime() 114 { 115 // Arrange - Calculate full recovery time from depleted state 116 float hoursToFullHealth = (PetConstants.MaxStatValue - PetConstants.MinStatValue) 117 / PetConstants.HealthRecoveryPerHour; 118 119 float hoursToFullFatigueRecovery = (PetConstants.MaxStatValue - PetConstants.MinStatValue) 120 / PetConstants.FatigueRecoveryPerHour; 121 122 // Assert - Should take a reasonable amount of time 123 Assert.InRange(hoursToFullHealth, 1f, 50f); 124 Assert.InRange(hoursToFullFatigueRecovery, 1f, 50f); 125 } 126 127 [Fact] 128 public void PetConstants_AllConstants_AreAccessible() 129 { 130 // Act & Assert - Verify all constants can be read without errors 131 var maxStat = PetConstants.MaxStatValue; 132 var minStat = PetConstants.MinStatValue; 133 var hungerIncrease = PetConstants.HungerIncreasePerHour; 134 var hydrationDecrease = PetConstants.HydrationDecreasePerHour; 135 var fatigueIncrease = PetConstants.FatigueIncreasePerHour; 136 var stressIncrease = PetConstants.StressIncreasePerHour; 137 var healthRecovery = PetConstants.HealthRecoveryPerHour; 138 var stressRecovery = PetConstants.StressRecoveryPerHour; 139 var fatigueRecovery = PetConstants.FatigueRecoveryPerHour; 140 141 // All values should be non-NaN and non-infinite 142 Assert.False(float.IsNaN(maxStat)); 143 Assert.False(float.IsInfinity(maxStat)); 144 Assert.False(float.IsNaN(minStat)); 145 Assert.False(float.IsInfinity(minStat)); 146 Assert.False(float.IsNaN(hungerIncrease)); 147 Assert.False(float.IsInfinity(hungerIncrease)); 148 Assert.False(float.IsNaN(hydrationDecrease)); 149 Assert.False(float.IsInfinity(hydrationDecrease)); 150 Assert.False(float.IsNaN(fatigueIncrease)); 151 Assert.False(float.IsInfinity(fatigueIncrease)); 152 Assert.False(float.IsNaN(stressIncrease)); 153 Assert.False(float.IsInfinity(stressIncrease)); 154 Assert.False(float.IsNaN(healthRecovery)); 155 Assert.False(float.IsInfinity(healthRecovery)); 156 Assert.False(float.IsNaN(stressRecovery)); 157 Assert.False(float.IsInfinity(stressRecovery)); 158 Assert.False(float.IsNaN(fatigueRecovery)); 159 Assert.False(float.IsInfinity(fatigueRecovery)); 160 } 161 }