Completed Persistance + BAG NOT WORKING
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
parent
c446099974
commit
68021750fe
@ -1 +1 @@
|
||||
<Leaderboard xmlns="http://schemas.datacontract.org/2004/07/QwirkleClassLibrary.Players" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><leaderboard><Score><Date>2024-05-31T00:00:00+02:00</Date><PlayerName>Jérémy</PlayerName><Points>0</Points><Victories>1</Victories></Score><Score><Date>2024-05-31T00:00:00+02:00</Date><PlayerName>Jules</PlayerName><Points>0</Points><Victories>0</Victories></Score></leaderboard></Leaderboard>
|
||||
{"leaderboard":[]}
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,42 @@
|
||||
using Xunit;
|
||||
using QwirkleClassLibrary.Games;
|
||||
using QwirkleClassLibrary.Persistences;
|
||||
using System.IO;
|
||||
|
||||
namespace TestBase
|
||||
{
|
||||
public class TestPersistence
|
||||
{
|
||||
[Fact]
|
||||
public void Test_SaveGame()
|
||||
{
|
||||
var game = new Game();
|
||||
|
||||
IGamePersistence gamePersistence = new GamePersistenceJson();
|
||||
gamePersistence.SaveGame(game);
|
||||
|
||||
Assert.True(File.Exists("Game.json"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Test_LoadGame()
|
||||
{
|
||||
Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory(), "..\\..\\..\\..\\Files"));
|
||||
|
||||
var game = new Game();
|
||||
|
||||
game.AddPlayerInGame(["Jules", "Jérémy"]);
|
||||
game.StartGame();
|
||||
|
||||
IGamePersistence gamePersistence = new GamePersistenceJson();
|
||||
gamePersistence.SaveGame(game);
|
||||
|
||||
var loadedGame = gamePersistence.LoadGame();
|
||||
|
||||
Assert.True(game.Board.ReadCells.All(cell =>
|
||||
cell.GetX == loadedGame.Board.GetCell(cell.GetX, cell.GetY)!.GetX &&
|
||||
cell.GetY == loadedGame.Board.GetCell(cell.GetX, cell.GetY)!.GetY &&
|
||||
cell.IsFree == loadedGame.Board.GetCell(cell.GetX, cell.GetY)!.IsFree));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue