test: main model
This commit is contained in:
parent
f721cee708
commit
859d34e3bb
5 changed files with 114 additions and 13 deletions
93
Assets/Scripts/Tests/ModelTests.cs
Normal file
93
Assets/Scripts/Tests/ModelTests.cs
Normal file
|
@ -0,0 +1,93 @@
|
|||
using Domain;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Tests {
|
||||
public class ModelTests {
|
||||
[Test]
|
||||
public void NoPress_NoAnimation() {
|
||||
Model sut = new(20, 5);
|
||||
|
||||
Assert.IsFalse(sut.NeedsToAnimate);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NotEnoughPresses_NoAnimation() {
|
||||
Model sut = new(20, 5);
|
||||
|
||||
sut.AddScore();
|
||||
|
||||
Assert.IsFalse(sut.NeedsToAnimate);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void EnoughPresses_Animation() {
|
||||
Model sut = new(20, 5);
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
sut.AddScore();
|
||||
|
||||
Assert.IsTrue(sut.NeedsToAnimate);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NoPress_NoSpawn() {
|
||||
Model sut = new(20, 5);
|
||||
|
||||
Assert.IsFalse(sut.NeedsToSpawn);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NotEnoughPresses_NoSpawn() {
|
||||
Model sut = new(20, 5);
|
||||
|
||||
sut.AddScore();
|
||||
|
||||
Assert.IsFalse(sut.NeedsToSpawn);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EnoughPresses_Spawn() {
|
||||
Model sut = new(20, 5);
|
||||
|
||||
for (int i = 0; i < 20 * 5; i++) {
|
||||
sut.AddScore();
|
||||
}
|
||||
|
||||
Assert.IsTrue(sut.NeedsToSpawn);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OneIteration_UpdatesGrowPercentage() {
|
||||
Model sut = new(5, 5);
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
sut.AddScore();
|
||||
}
|
||||
|
||||
Assert.AreEqual(1f / 5f, sut.GrowPercentage);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AllIterations_GrowCompleted() {
|
||||
Model sut = new(5, 5);
|
||||
|
||||
for (int i = 0; i < 5 * 5; i++) {
|
||||
sut.AddScore();
|
||||
}
|
||||
|
||||
Assert.AreEqual(1f, sut.GrowPercentage);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MoreIterations_ResetsGrowPercentage() {
|
||||
Model sut = new(5, 5);
|
||||
|
||||
for (int i = 0; i < 6 * 5; i++) {
|
||||
sut.AddScore();
|
||||
}
|
||||
|
||||
Assert.AreEqual(1f / 5f, sut.GrowPercentage);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue