public void TestDeskCheckError() { Desk tempDesk1 = new Desk(); int coloum = 0, row = 0; for (Card.Type type = Card.Type.Diamonds; type <= Card.Type.Club; type++) { for (int i = 1; i <= 13; i++) { tempDesk1.AddNewCardInColoum(coloum, new Card(type, (Card.Number)i)); coloum++; if (coloum == tempDesk1.AllCardOnDesk.ColoumCard.GetLength(0)) { row++; coloum = 0; } } } tempDesk1.CheckError(); Card tempCard = tempDesk1.RemoveLastCardInColoum(0); try { tempDesk1.CheckError(); throw new Exception("Test failed"); } catch (ErrorInDeskException) { } tempDesk1.AllCardOnDesk.FreeCard[0] = tempCard; tempDesk1.CheckError(); Desk tempDesk2 = new Desk(); for (Card.Type type = Card.Type.Diamonds; type <= Card.Type.Spade; type++) { for (int i = 1; i <= 13; i++) { tempDesk2.AddNewCardInColoum(coloum, new Card(type, (Card.Number)i)); coloum++; if (coloum == tempDesk2.AllCardOnDesk.ColoumCard.GetLength(0)) { row++; coloum = 0; } } } for (Card.Number i = Card.Number.Arch; i <= Card.Number.King; i++) { tempDesk2.AddNewCardInSortedCard(new Card(Card.Type.Club, i), true); } tempDesk2.CheckError(); }
public override void Execute() { string location = CommandManager.GetInstance().RemainCommand.Trim(); string json; try { json = File.ReadAllText(location); } catch (FileNotFoundException) { Console.WriteLine("File not found"); return; } Desk targetDesk = Desk.GetDeskFromJson(json); Console.WriteLine(targetDesk.Pretty()); try { targetDesk.CheckError(); Console.WriteLine("No error"); } catch (ErrorInDeskException e) { Console.WriteLine(e); } }
public override void Execute() { string location = CommandManager.GetInstance().RemainCommand.Trim(); string json; try { json = File.ReadAllText(location); } catch (FileNotFoundException) { Console.WriteLine("File not found"); return; } Desk targetDesk = Desk.GetDeskFromJson(json); Console.WriteLine(targetDesk.Pretty()); try { targetDesk.CheckError(); } catch (ErrorInDeskException e) { Console.WriteLine($"Error: {e}"); return; } InferManager.GetInstance().ClearInferData(); InferManager.GetInstance().SetStartDesk(targetDesk); var result = InferManager.GetInstance().StartInfer(); Console.WriteLine(result.Message); foreach (var singleProcedure in result.Procedures) { Console.WriteLine(singleProcedure.MoveMessage); } }