-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make tests use the new GameSession[Turn|Controller]; add test: TurnCo…
…ntrollerAdvancesTurns
- Loading branch information
Konrad Jamrozik
committed
Jun 7, 2024
1 parent
dc1a5fe
commit fe60208
Showing
8 changed files
with
96 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using Lib.Contracts; | ||
using Lib.OS; | ||
using UfoGameLib.Controller; | ||
using UfoGameLib.Lib; | ||
using UfoGameLib.Players; | ||
using UfoGameLib.State; | ||
|
||
namespace UfoGameLib.Tests; | ||
|
||
public class GameSessionControllerTests | ||
{ | ||
private Configuration _config = null!; | ||
private ILog _log = null!; | ||
private readonly RandomGen _randomGen = new RandomGen(new Random()); | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
_config = new Configuration(new FileSystem()); | ||
_log = new Log(_config); | ||
} | ||
|
||
|
||
[Test] | ||
public void TurnControllerAdvancesTurns() | ||
{ | ||
var session = new GameSession2(_randomGen); | ||
var controller = new GameSessionController2(_config, _log, session); | ||
var turnController = controller.TurnController; | ||
|
||
int initialTurn = session.CurrentGameState.Timeline.CurrentTurn; | ||
|
||
Assert.That(turnController.CurrentTurn, Is.EqualTo(session.CurrentGameState.Timeline.CurrentTurn)); | ||
|
||
// Act | ||
controller.PlayGameSession(2, new AIPlayer(_log, AIPlayer.Intellect.DoNothing)); | ||
|
||
int newTurn = session.CurrentGameState.Timeline.CurrentTurn; | ||
|
||
Contract.Assert(initialTurn + 1 == newTurn); | ||
Assert.That(turnController.CurrentTurn, Is.EqualTo(session.CurrentGameState.Timeline.CurrentTurn)); | ||
} | ||
|
||
|
||
[TearDown] | ||
public void TearDown() | ||
{ | ||
_log.Dispose(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters