Initial commit: Tiny Tackle Heroes Unity project
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
using BumpCombat.Core;
|
||||
using System.Reflection;
|
||||
using BumpCombat.Player;
|
||||
using BumpCombat.Progression;
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BumpCombat.Tests
|
||||
{
|
||||
public sealed class ExperienceSystemTests
|
||||
{
|
||||
[TestCase(1, 10)]
|
||||
[TestCase(2, 15)]
|
||||
[TestCase(3, 20)]
|
||||
[TestCase(10, 55)]
|
||||
public void RequiredExperienceForLevel_UsesWorkOrderFormula(int level, int expected)
|
||||
{
|
||||
Assert.That(ExperienceSystem.RequiredExperienceForLevel(level), Is.EqualTo(expected));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddExperience_UsesPlayerStatsExperienceGain()
|
||||
{
|
||||
GameObject owner = new("ExperienceSystem Tests");
|
||||
try
|
||||
{
|
||||
PlayerStats stats = owner.AddComponent<PlayerStats>();
|
||||
ExperienceSystem experience = owner.AddComponent<ExperienceSystem>();
|
||||
typeof(ExperienceSystem)
|
||||
.GetMethod(
|
||||
"Awake",
|
||||
BindingFlags.Instance | BindingFlags.NonPublic)
|
||||
?.Invoke(experience, null);
|
||||
stats.AddModifier(new StatModifier(
|
||||
"experience-increased",
|
||||
CharacterStat.ExperienceGain,
|
||||
ModifierOperation.Increased,
|
||||
0.1f));
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
experience.AddExperience(1);
|
||||
}
|
||||
|
||||
Assert.That(experience.Level, Is.EqualTo(2));
|
||||
Assert.That(experience.CurrentExperience, Is.EqualTo(1));
|
||||
}
|
||||
finally
|
||||
{
|
||||
Object.DestroyImmediate(owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user