public void TestMethod_GMRequestHandler_GameOver() { string expected = "{\"action\":\"end\",\"result\":\"blue\"}"; string actual = GMRequestHandler.SendGameOver(Team.TeamColor.BLUE); Assert.AreEqual(expected, actual); }
public void TestMethod_GMRequestHandler_BeginGame() { Player p1 = new Player() { role = Player.Role.LEADER, playerID = "0", Row = 0, Column = 0, //toCheck = true, Team = Team.TeamColor.RED }; Player p2 = new Player() { role = Player.Role.MEMBER, playerID = "1", Row = 1, Column = 10, //toCheck = true, Team = Team.TeamColor.RED }; List <Player> listp = new List <Player>() { p1, p2 }; string actual = GMRequestHandler.BeginGame(p2, listp, p1); string expected = "{\r\n \"action\": \"begin\",\r\n \"userGuid\": \"1\",\r\n \"team\": \"red\",\r\n \"role\": \"member\",\r\n \"teamSize\": \"2\",\r\n \"teamGuids\": [\r\n \"0\",\r\n \"1\"\r\n ],\r\n \"location\": {\r\n \"x\": \"10\",\r\n \"y\": \"1\"\r\n },\r\n \"board\": {\r\n \"width\": \"0\",\r\n \"tasksHeight\": \"0\",\r\n \"goalsHeight\": \"0\"\r\n }\r\n}"; Assert.AreEqual(expected, actual); }
public void TestMethod_GMRequestHandler_ForResponses() { /*Response for move */ Player pl = new Player() { playerID = "1", role = Player.Role.LEADER, Row = 0, Column = 0, //toCheck = true, Team = Team.TeamColor.BLUE }; string expected_move = "{\"action\":\"move\",\"userGuid\":\"1\",\"result\":\"OK\",\"timestamp\":69,\"manhattanDistance\":7}"; string actual_move = GMRequestHandler.ResponseForMove(pl); Assert.AreEqual(expected_move, actual_move); /*Response for discover */ string expected_discover = "{\"action\":\"state\",\"userGuid\":\"1\",\"result\":\"OKdenied\",\"scope\":{\"x\":\"01234...board\",\"y\":\"01234...board\"},\"fields\":[{\"x\":\"01234...board\",\"y\":\"01234...board\",\"value\":{\"manhattanDistance\":\"null012...Nearest\",\"contains\":\"goalpieceempty\",\"timestamp\":\"2137\",\"userGuid\":\"fa3f3cb5-742d-478f-9e02-230679032777\"}}]}"; string actual_discover = GMRequestHandler.ResponseForDiscover(pl); Assert.AreEqual(expected_discover, actual_discover); /* Response for pick up */ string expected_pickup = "{\"action\":\"pickup\",\"userGuid\":\"1\",\"result\":\"OK\",\"timestamp\":\"420\"}"; string actual_pickup = GMRequestHandler.ResponseForPickUp(pl); Assert.AreEqual(expected_pickup, actual_pickup); /* Response for test piece */ string expected_test = "{\"action\":\"test\",\"userGuid\":\"1\",\"result\":\"OK\",\"test\":\"false\"}"; string actual_test = GMRequestHandler.ResponseForTestPiece(pl); Assert.AreEqual(expected_test, actual_test); /* Response for destroy player*/ string expected_dest = "{\"action\":\"destroy\",\"userGuid\":\"1\",\"result\":\"OK\"}"; string actual_dest = GMRequestHandler.ResponseForDestroyPiece(pl); Assert.AreEqual(expected_dest, actual_dest); /* Response for place piece*/ string expected_place = "{\"action\":\"place\",\"userGuid\":\"1\",\"result\":\"OK\",\"consequence\":\"correct meaningless null\",\"timestamp\":\"null\"}"; string actual_place = GMRequestHandler.ResponseForPlacePiece(pl); Assert.AreEqual(expected_place, actual_place); }
public void TestMethod_GMRequestHandler_ConnectPlayerOK() { Player pl = new Player() { playerID = "1", role = Player.Role.LEADER, Row = 0, Column = 0, //toCheck = true, Team = Team.TeamColor.BLUE }; string file0 = @"C:\Users\julia\source\repos\theprojectgame\TheGame\TheGame\JSONs\ConfirmJoiningGame.json"; string json = File.ReadAllText(file0, Encoding.ASCII);; //dynamic expected = JsonConvert.DeserializeObject(json); dynamic expected = "{\"action\":\"connect\",\"userGuid\":\"1\",\"result\":\"OK\",\"type\":\"player\"}"; //expected.userGuid = pl.playerID; dynamic actual = GMRequestHandler.ConnectPlayerOK(pl); Assert.AreEqual(expected, actual); }
public void TestMethod_ForGMRequestHandler() { /* for SendSetUpGame */ string file = @"C:\Users\julia\source\repos\theprojectgame\TheGame\TheGame\JSONs\SetUpGame.json"; string expected = File.ReadAllText(file, Encoding.ASCII);; string actual = GMRequestHandler.SendSetUpGame(); Assert.AreNotEqual(expected, actual); /*for ConnectPlayerOK */ Player pl = new Player() { role = Player.Role.LEADER, //playerID = 0, Row = 0, Column = 0, //toCheck = true, Team = Team.TeamColor.BLUE }; //string file0 = @"C:\Users\julia\source\repos\theprojectgame\TheGame\TheGame\JSONs\ConfirmJoiningGame.json"; //string json = File.ReadAllText(file0, Encoding.ASCII); ; //dynamic expected0 = JsonConvert.DeserializeObject(json); //expected0.userGuid = pl.playerID; //dynamic actual0 = GMRequestHandler.ConnectPlayerOK(pl); //Assert.AreEqual(expected0, actual0); /* for ConnectPlayerDeny */ /* for BeginGame */ //string res = GMRequestHandler.BeginGame(p2, listp, p1); /* for ResponseForDiscover */ }