/// <summary> /// Sends request for solution of the problem. /// </summary> /// <param name="id">The ID of the problem instance assigned by the server.</param> /// <returns>Solutions message(s) or null if server is not responding.</returns> public List<SolutionsMessage> SendSolutionRequest(ulong id) { var solutionRequestMessage = new SolutionRequestMessage { ProblemInstanceId = id }; var receivedMessages = SendMessage(solutionRequestMessage); if (receivedMessages == null) return null; var solutionsMessages = new List<SolutionsMessage>(); foreach (var receivedMessage in receivedMessages) { SolutionsMessage solutionsMessage; if ((solutionsMessage = receivedMessage as SolutionsMessage) != null) { solutionsMessages.Add(solutionsMessage); } else { RaiseEvent(MessageHandlingException, receivedMessage, new InvalidOperationException("SolutionsMessage expected.")); } } return solutionsMessages; }
public void SolutionRequestMessageXmlIsProperlySerializedAndDeserialized() { var message = new SolutionRequestMessage { ProblemInstanceId = 5 }; var serializedMessage = _serializer.Serialize(message); var deserializedMessage = _serializer.Deserialize(serializedMessage); Assert.IsInstanceOfType(deserializedMessage, typeof (SolutionRequestMessage)); }