public void Parse_RequestMoveInstruction_12345ms() { var act = Instruction.Parse("Action player1 12345"); var exp = new RequestMoveInstruction(PlayerName.player1, TimeSpan.FromMilliseconds(12345)); Assert.AreEqual(exp, act); }
public static IInstruction Parse(string line) { var splited = line.Split(' '); switch (splited[0].ToUpperInvariant()) { case "ACTION": return RequestMoveInstruction.Parse(splited); case "SETTINGS": return SettingsInstruction.Parse(splited); case "MATCH": return MatchInstruction.Parse(splited); case "PLAYER1": case "PLAYER2": return PlayerInstruction.Parse( (PlayerName)Enum.Parse(typeof(PlayerName), splited[0], true), splited); } return null; }