public void TestResponsePacketConstructor() { string action = "Add Member"; string sessionID = "1209384209385"; string data = "This is super important data >_>'"; string response = "The member 123456789 was succesfully added."; ResponsePacket testPacket = new ResponsePacket(action, sessionID, data, response); Assert.AreEqual(data, testPacket.Data()); Assert.AreEqual(response, testPacket.Response()); return; }
/// <summary> /// Build a login packet from user input from the packet factory. Send /// the packet to the server for processing. The server will send back a /// session id if login was successful. /// </summary> /// <returns>True</returns> private bool LoginUpdate() { if (tui == null) { // Exception. } LoginPacket loginPacket = null; // Build a login packet. if (MockMode == true) { loginPacket = MockPacket as LoginPacket; } else { loginPacket = packetFactory.BuildPacket( tui, "LoginPacket", "", "", "", AccessLevel()) as LoginPacket; } // Send the packet to the server and instantiate a response. ResponsePacket responsePacket = server.ProcessAction(loginPacket); if (MockMode == true) { MockPacket = responsePacket as ResponsePacket; } // Get the session id from the response packet. this.sessionID = responsePacket.Data(); // If we got a valid session from the server (md5 is length 32) if (this.sessionID.Length == 32) { // Login! Success! userID = loginPacket.ID(); // Change state to menu. currentState = TerminalState.MENU; } else { // Something went wrong with login information, show the operator the response. WriteResponse(responsePacket); } return(MockMode == true ? false : true); }