public static SolutionsMessage CreateSolutionsMessage() { string problemType = "TSP"; ulong id = 12; byte[] commonData = { 1, 23, 25, 2, 5, 5, 5, 5, 2, 26, 87 }; // fields for Solution1 ulong taskId1 = 123; bool timeoutOccured1 = false; SolutionsSolutionType typeField1 = SolutionsSolutionType.Final; ulong computationsTime1 = 12334; byte[] data1 = { 24, 252, 6, 43, 57, 88 }; Solution solution1 = new Solution(taskId1, timeoutOccured1, typeField1, computationsTime1, data1); // fields for Solution2 ulong taskId2 = 321; bool timeoutOccured2 = true; SolutionsSolutionType typeField2 = SolutionsSolutionType.Ongoing; ulong computationsTime2 = 43321; byte[] data2 = { 24, 25, 6, 3, 7, 8 }; Solution solution2 = new Solution(taskId2, timeoutOccured2, typeField2, computationsTime2, data2); Solution[] solutions = { solution1, solution2 }; SolutionsMessage expectedMessage = new SolutionsMessage(problemType, id, commonData, solutions); return(expectedMessage); }
/// <summary> /// /// </summary> /// <param name="taskId"> /// Id of subproblem given by TaskManager – no TaskId for /// final/merged solution /// </param> /// <param name="timeoutOccured"> /// Indicator that the computations ended because of timeout /// </param> /// <param name="type"> /// Information about the status of result (Partial/Final) or status /// of computations (Ongoing) /// </param> /// <param name="computationsTime"> /// Total amount of time used by all threads in system for computing /// the solution / during the ongoing computations (in ms) /// </param> /// <param name="data"> /// Solution data /// </param> public Solution(ulong taskId, bool timeoutOccured, SolutionsSolutionType type, ulong computationsTime, byte[] data) { TaskId = taskId; TimeoutOccured = timeoutOccured; Type = type; ComputationsTime = computationsTime; Data = data; taskIdFieldSpecified = true; }
public void Parse_XMLString_SolutionMessage() { /*********** Actual message ***********/ string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"xml_samples\Solutions.xml"); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(path); string xmlStr = xmlDoc.OuterXml; string name = Message.GetMessageName(xmlStr); SolutionsMessage actualMessage = null; if (name == SolutionsMessage.ELEMENT_NAME) { actualMessage = SolutionsMessage.Construct(xmlStr); } /*********** Expected message ***********/ // construct fields for SolutionsMessage string problemType = "TSP"; ulong id = 12; byte[] commonData = { 1, 23, 25, 2, 5, 5, 5, 5, 2, 26, 87 }; // fields for Solution1 ulong taskId1 = 123; bool timeoutOccured1 = false; SolutionsSolutionType typeField1 = SolutionsSolutionType.Final; ulong computationsTime1 = 12334; byte[] data1 = { 24, 252, 6, 43, 57, 88 }; Solution solution1 = new Solution(taskId1, timeoutOccured1, typeField1, computationsTime1, data1); // fields for Solution2 ulong taskId2 = 321; bool timeoutOccured2 = true; SolutionsSolutionType typeField2 = SolutionsSolutionType.Ongoing; ulong computationsTime2 = 43321; byte[] data2 = { 24, 25, 6, 3, 7, 8 }; Solution solution2 = new Solution(taskId2, timeoutOccured2, typeField2, computationsTime2, data2); Solution[] solutions = { solution1, solution2 }; SolutionsMessage expectedMessage = new SolutionsMessage(problemType, id, commonData, solutions); Assert.AreEqual(expectedMessage, actualMessage); }
public Solution(SolutionsSolutionType type) { Type = type; }