Finished scoring system and started tests

This commit is contained in:
KäseToatz
2024-11-06 21:46:37 +01:00
parent 23ae45ba91
commit af7457a9d9
13 changed files with 265 additions and 50 deletions

36
Memory.Test/GameTest.cs Normal file
View File

@ -0,0 +1,36 @@
using Memory.Logic;
using Memory.Data;
namespace Memory.Test
{
[TestClass]
public class GameTest
{
[TestMethod]
public void IncreaseScore_QuarterTime_ShouldEqual75PercentOfPoints()
{
int score = (int)(Game.MAXPOINTS * 0.75);
Game game = new(new ScoreHandler());
Thread.Sleep(Game.MAXTIME / 4);
game.IncreaseScore();
Assert.IsTrue(score - 1 <= game.Score && score + 1 >= game.Score);
}
[TestMethod]
public void IncreaseScore_TooLong_ShouldEqualLowerBoundOfPoints()
{
Game game = new(new ScoreHandler());
Thread.Sleep(Game.MAXTIME);
game.IncreaseScore();
Assert.AreEqual(Game.MINPOINTS, game.Score);
}
[TestMethod]
public void IncreaseScore_Instant_ShouldEqualUpperBoundOfPoints()
{
Game game = new(new ScoreHandler());
game.IncreaseScore();
Assert.AreEqual(Game.MAXPOINTS, game.Score);
}
}
}

View File

@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Memory.Data\Memory.Data.csproj" />
<ProjectReference Include="..\Memory.Logic\Memory.Logic.csproj" />
</ItemGroup>
<ItemGroup>
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
</ItemGroup>
</Project>