diff --git a/Chrono/Chrono.sln b/Chrono/Chrono.sln index 91001c9..95e905f 100644 --- a/Chrono/Chrono.sln +++ b/Chrono/Chrono.sln @@ -8,6 +8,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model", "Model\Model.csproj EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Deploy", "Deploy\Deploy.csproj", "{E5E9A799-76C8-43B3-B9C2-3CAEC2B5E1DD}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{90F32056-6983-4224-8A8C-E797C71633F3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -30,5 +32,9 @@ Global {E5E9A799-76C8-43B3-B9C2-3CAEC2B5E1DD}.Debug|Any CPU.Build.0 = Debug|Any CPU {E5E9A799-76C8-43B3-B9C2-3CAEC2B5E1DD}.Release|Any CPU.ActiveCfg = Release|Any CPU {E5E9A799-76C8-43B3-B9C2-3CAEC2B5E1DD}.Release|Any CPU.Build.0 = Release|Any CPU + {90F32056-6983-4224-8A8C-E797C71633F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {90F32056-6983-4224-8A8C-E797C71633F3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {90F32056-6983-4224-8A8C-E797C71633F3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {90F32056-6983-4224-8A8C-E797C71633F3}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/Chrono/Tests/Tests.cs b/Chrono/Tests/Tests.cs new file mode 100644 index 0000000..55cdbad --- /dev/null +++ b/Chrono/Tests/Tests.cs @@ -0,0 +1,55 @@ +using Chrono.Model; + +namespace Tests; + +public class CardDataTests +{ + [Test] + public void StatEfficiency_CalculatesCorrectly() + { + var card = new CardData { Cost = 2, Attack = 2, Health = 3 }; + Assert.That(card.StatEfficiency, Is.EqualTo(2.5f)); + } + + [Test] + public void StatEfficiency_ReturnsZero_WhenCostIsZero() + { + var card = new CardData { Cost = 0, Attack = 2, Health = 3 }; + Assert.That(card.StatEfficiency, Is.EqualTo(0f)); + } + + [Test] + public void StatEfficiency_ReturnsZero_WhenAttackIsNull() + { + var card = new CardData { Cost = 2, Attack = null, Health = 3 }; + Assert.That(card.StatEfficiency, Is.EqualTo(0f)); + } + + [Test] + public void IsAgent_ReturnsTrue_WhenCategoryIsAgent() + { + var card = new CardData { Category = "Agent" }; + Assert.That(card.IsAgent, Is.True); + } + + [Test] + public void IsSpell_ReturnsTrue_WhenCategoryIsSpell() + { + var card = new CardData { Category = "Spell" }; + Assert.That(card.IsSpell, Is.True); + } + + [Test] + public void ImagePath_UsesPlaceholder_WhenImageFileIsNull() + { + var card = new CardData { ImageFile = null }; + Assert.That(card.ImagePath, Is.EqualTo("cards/placeholder.png")); + } + + [Test] + public void StatEfficiency_RoundsToTwoDecimalPlaces() + { + var card = new CardData { Cost = 3, Attack = 1, Health = 1 }; // (1+1)/3 = 0.666... + Assert.That(card.StatEfficiency, Is.EqualTo(0.67f)); + } +} \ No newline at end of file diff --git a/Chrono/Tests/Tests.csproj b/Chrono/Tests/Tests.csproj new file mode 100644 index 0000000..7606a27 --- /dev/null +++ b/Chrono/Tests/Tests.csproj @@ -0,0 +1,28 @@ + + + + net10.0 + latest + enable + enable + false + + + + + + + + + + + + + + + + + + + +