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("./../../../../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)); } } }