lots of staff
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
using Snake.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using Microsoft.Extensions.Time.Testing;
|
||||
|
||||
namespace tests.Model
|
||||
{
|
||||
public class SnakeLevelTest
|
||||
{
|
||||
FakeTimeProvider timeProvider = new FakeTimeProvider();
|
||||
SnakeLevel level;
|
||||
Point[] obstacles = [(3, 3), (4, 4)];
|
||||
public SnakeLevelTest()
|
||||
{
|
||||
level = new SnakeLevel(
|
||||
10, obstacles,
|
||||
5, 3, 2, timeProvider
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SnakeInitialValuesTests()
|
||||
{
|
||||
level.SnakeHeadDirection.Should().Be(SnakeLevel.SnakeDirection.Down);
|
||||
level.SnakeLength.Should().Be(5);
|
||||
level.EggLimit.Should().Be(2);
|
||||
level.NewEggRound.Should().Be(3);
|
||||
level.Size.Should().Be(10);
|
||||
level.State.Should().Be(SnakeLevel.GameState.Paused);
|
||||
foreach(Point p in obstacles)
|
||||
{
|
||||
level[p].Should().Be(SnakeLevel.LevelBlock.Obstacle);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SnakeOutOfBoundsTest()
|
||||
{
|
||||
bool game_state_changed_raised = false;
|
||||
level.GameStateUpdate += (s, e) =>
|
||||
{
|
||||
game_state_changed_raised = true;
|
||||
};
|
||||
|
||||
level.Start();
|
||||
|
||||
game_state_changed_raised.Should().Be(true);
|
||||
game_state_changed_raised = false;
|
||||
for(int i=0; i<5; i++)
|
||||
{
|
||||
timeProvider.Advance(SnakeLevel.TickTimeSpan);
|
||||
}
|
||||
|
||||
game_state_changed_raised.Should().Be(false);
|
||||
|
||||
timeProvider.Advance(SnakeLevel.TickTimeSpan);
|
||||
game_state_changed_raised.Should().Be(true);
|
||||
level.State.Should().Be(SnakeLevel.GameState.Dead);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user