@ -8,33 +8,30 @@ namespace TestBase;
public class TestGame
{
[Theory]
[InlineData(true, false, "test t")]
[InlineData(false, false, "test t")]
[InlineData(false, true, "test t")]
public void Test_GameAddPlayerIngame ( bool result , bool gamestate , string p )
[InlineData(true, false, "test", "test1")]
[InlineData(false, false, "test", "test1")]
[InlineData(false, true, "test ", " test1 ")]
public void Test_GameAddPlayerIngame ( bool result , bool gamestate , string p 1, string p2 )
{
Game game = new Game ( ) ;
List < string > players = [ p1 , p2 ] ;
if ( ! result )
{
game . AddPlayerInGame ( p ) ;
Assert . False ( game . AddPlayerInGame ( p ) ) ;
game . AddPlayerInGame ( p layers ) ;
Assert . False ( game . AddPlayerInGame ( p layers ) ) ;
}
else
{
Assert . True ( game . AddPlayerInGame ( p ) ) ;
Assert . True ( game . AddPlayerInGame ( p layers ) ) ;
}
if ( gamestate )
{
game . StartGame ( ) ;
Assert . False ( game . AddPlayerInGame ( p ) ) ;
Assert . False ( game . AddPlayerInGame ( p layers ) ) ;
}
}
[Theory]
@ -43,21 +40,32 @@ public class TestGame
public void Test_GameAddPlayerIngame2 ( bool result , string p )
{
Game game = new Game ( ) ;
List < string > players = new List < string > ( ) ;
if ( ! result )
{
Assert . False ( game . AddPlayerInGame ( p ) ) ;
players . Add ( p ) ;
Assert . False ( game . AddPlayerInGame ( players ) ) ;
}
players . Clear ( ) ;
for ( int i = 0 ; i < 4 ; i + + )
{
string name = p + i ;
game. AddPlayerInGame ( name ) ;
players. Add ( name ) ;
}
Assert . False ( game . AddPlayerInGame ( p ) ) ;
Assert . True ( game . AddPlayerInGame ( players ) ) ;
}
[Fact]
public void Test_AddPlayers ( )
{
Game game = new Game ( ) ;
List < string > playerstest = new List < string > { "test" , "test1" } ;
Assert . True ( game . AddPlayerInGame ( playerstest ) ) ;
}
[Theory]
[InlineData("test")]
public void Test_GameCreatePlayers ( string p )
@ -79,8 +87,8 @@ public class TestGame
game . StartGame ( ) ;
Assert . False ( game . GameRunning ) ;
}
game. AddPlayerInGame ( p1 ) ;
game . AddPlayerInGame ( p 2 ) ;
List< string > playerstest = [ "test" , "test1" ] ;
game . AddPlayerInGame ( p layerstest ) ;
game . StartGame ( ) ;
Assert . True ( game . GameRunning ) ;
@ -93,9 +101,8 @@ public class TestGame
public void Test_GameGetPlayingPlayerPosition ( bool result , string p1 , string p2 , string p3 )
{
Game game = new Game ( ) ;
game . AddPlayerInGame ( p1 ) ;
game . AddPlayerInGame ( p2 ) ;
game . AddPlayerInGame ( p3 ) ;
List < string > playerstest = [ "test" , "test1" , "test2" ] ;
game . AddPlayerInGame ( playerstest ) ;
if ( ! result )
{
@ -113,8 +120,8 @@ public class TestGame
public void Test_GameGetPlaylingPlayer ( bool result )
{
Game game = new Game ( ) ;
game. AddPlayerInGame ( "patrick" ) ;
game . AddPlayerInGame ( "jean" ) ;
List< string > playerstest = [ "test" , "test1" ] ;
game . AddPlayerInGame ( playerstest ) ;
if ( ! result )
{
Assert . Throws < ArgumentException > ( ( ) = > game . GetPlayingPlayer ( ) ) ;
@ -130,8 +137,8 @@ public class TestGame
public void Test_BoardReturn ( )
{
Game game = new Game ( ) ;
game. AddPlayerInGame ( "Test1" ) ;
game . AddPlayerInGame ( "Test2" ) ;
List< string > playerstest = [ "test" , "test1" ] ;
game . AddPlayerInGame ( playerstest ) ;
game . StartGame ( ) ;
game . SetFirstPlayer ( ) ;
@ -144,8 +151,8 @@ public class TestGame
Game game = new Game ( ) ;
game. AddPlayerInGame ( "Test1" ) ;
game . AddPlayerInGame ( "Test2" ) ;
List< string > playerstest = [ "test" , "test1" ] ;
game . AddPlayerInGame ( playerstest ) ;
game . StartGame ( ) ;
game . SetFirstPlayer ( ) ;
@ -164,8 +171,8 @@ public class TestGame
public void Test_TileOfPlayer ( )
{
Game game = new Game ( ) ;
game. AddPlayerInGame ( "Test1" ) ;
game . AddPlayerInGame ( "Test2" ) ;
List< string > playerstest = [ "test" , "test1" ] ;
game . AddPlayerInGame ( playerstest ) ;
game . StartGame ( ) ;
game . SetFirstPlayer ( ) ;
@ -181,8 +188,8 @@ public class TestGame
public void Test_SetFirstPlayer ( bool except )
{
Game game = new Game ( ) ;
game. AddPlayerInGame ( "Test1" ) ;
game . AddPlayerInGame ( "Test2" ) ;
List< string > playerstest = [ "test" , "test1" ] ;
game . AddPlayerInGame ( playerstest ) ;
if ( except )
{
@ -201,8 +208,8 @@ public class TestGame
public void Test_Setnextplayer ( bool except )
{
Game game = new Game ( ) ;
game. AddPlayerInGame ( "Test1" ) ;
game . AddPlayerInGame ( "Test2" ) ;
List< string > playerstest = [ "test" , "test1" ] ;
game . AddPlayerInGame ( playerstest ) ;
if ( except )
{
@ -224,8 +231,8 @@ public class TestGame
public void Test_PlaceTile ( bool except )
{
Game game = new Game ( ) ;
game. AddPlayerInGame ( "Test1" ) ;
game . AddPlayerInGame ( "Test2" ) ;
List< string > playerstest = [ "test" , "test1" ] ;
game . AddPlayerInGame ( playerstest ) ;
if ( except )
{
@ -247,7 +254,7 @@ public class TestGame
// {
// Game game = new Game();
// game.AddPlayerInGame("Test1");
// game.AddPlayerInGame("Test2" );
// game.AddPlayerInGame(playerstest );
/ /
// game.StartGame();
// game.SetNextPlayer();
@ -267,8 +274,8 @@ public class TestGame
public void Test_SwapTiles ( bool except )
{
Game game = new Game ( ) ;
game. AddPlayerInGame ( "Test1" ) ;
game . AddPlayerInGame ( "Test2" ) ;
List< string > playerstest = [ "test" , "test1" ] ;
game . AddPlayerInGame ( playerstest ) ;
game . StartGame ( ) ;
game . SetNextPlayer ( ) ;
@ -302,8 +309,8 @@ public class TestGame
public void Test_IsMoveCorrectOne ( bool except )
{
Game game = new Game ( ) ;
game. AddPlayerInGame ( "Test1" ) ;
game . AddPlayerInGame ( "Test2" ) ;
List< string > playerstest = [ "test" , "test1" ] ;
game . AddPlayerInGame ( playerstest ) ;
game . StartGame ( ) ;
game . SetNextPlayer ( ) ;
@ -328,8 +335,8 @@ public class TestGame
public void Test_IsMoveCorrectSixLine ( )
{
Game game = new Game ( ) ;
game. AddPlayerInGame ( "Test1" ) ;
game . AddPlayerInGame ( "Test2" ) ;
List< string > playerstest = [ "test" , "test1" ] ;
game . AddPlayerInGame ( playerstest ) ;
game . StartGame ( ) ;
game . SetNextPlayer ( ) ;
@ -364,10 +371,10 @@ public class TestGame
var game = new Game ( ) ;
var player = new Player ( "TestPlayer" ) ;
var board = new Board ( 8 , 8 ) ;
board . AddTileInCell ( 1 , 1 , new Tile ( Shape . Club , Color . Red ) ) ;
board . AddTileInCell ( 2 , 1 , new Tile ( Shape . Square , Color . Red ) ) ;
var c1 = new Cell ( x1 , y1 ) ;
var c2 = new Cell ( x2 , y2 ) ;
var c3 = new Cell ( x3 , y3 ) ;
@ -387,33 +394,34 @@ public class TestGame
Assert . Equal ( expectedScore , score ) ;
}
[Fact]
public void Test_EndOfGame ( )
{
Game game = new Game ( ) ;
game . AddPlayerInGame ( "Test1" ) ;
game . AddPlayerInGame ( "Test2" ) ;
List < string > playerstest = [ "test" , "test1" ] ;
game . AddPlayerInGame ( playerstest ) ;
game . StartGame ( ) ;
game . SetFirstPlayer ( ) ;
game . CheckGameOver ( game . GetPlayingPlayer ( ) ) ;
}
[Fact]
public void Test_ClearGame ( )
{
Game game = new Game ( ) ;
game. AddPlayerInGame ( "Test1" ) ;
game . AddPlayerInGame ( "Test2" ) ;
List< string > playerstest = [ "test" , "test1" ] ;
game . AddPlayerInGame ( playerstest ) ;
game . StartGame ( ) ;
game . SetFirstPlayer ( ) ;
game . ClearGame ( ) ;
Assert . Empty ( game . PlayerList ) ;
Assert . Null ( game . GetTileBag ( ) ) ;
Assert . Equal ( - 1 , game . GetPlayingPlayerPosition ( ) ) ;
@ -421,3 +429,4 @@ public class TestGame
}