private void CompareMessages() { try { matchedList = new List <TagValue>(); missingList = new List <TagValue>(); extraList = new List <TagValue>(); matchedList1 = new List <TagValue>(); missingTags = new List <TagValue>(); extraTags = new List <TagValue>(); incorrectValueTags = new List <TagValue>(); List <int> ignore = ConfigurationSingleton.Instance.TagsToIgnore(); // Basic Matching - every value is a string! foreach (TagValue tv in expectedList) { if (!ignore.Contains(tv.Tag)) { if (actualList.Contains(tv)) { matchedList.Add(tv); } else if (!actualList.Contains(tv)) { missingList.Add(tv); } } } foreach (TagValue tv in actualList) { if (!ignore.Contains(tv.Tag)) { if (!expectedList.Contains(tv)) { extraList.Add(tv); } } } // Complex Matching - converted to relevant Val type first i.e. compare 0.0000 to 0.000000 foreach (KeyValuePair <int, string> kvp in expectedDictionary) { if (!ignore.Contains(kvp.Key)) { if (actualDictionary.ContainsKey(kvp.Key)) { Field f = Fields.Instance.GetField(kvp.Key); if (FixDataTypes.Compare(f, kvp.Value, actualDictionary[kvp.Key].ToString())) { TagValue tv = new TagValue(kvp.Key, kvp.Value); matchedList1.Add(tv); } else { TagValue tv = new TagValue(kvp.Key, actualDictionary[kvp.Key]); incorrectValueTags.Add(tv); } } else { TagValue tv = new TagValue(kvp.Key, kvp.Value); missingTags.Add(tv); } } } foreach (KeyValuePair <int, string> kvp in actualDictionary) { if (!ignore.Contains(kvp.Key)) { if (!expectedDictionary.ContainsKey(kvp.Key)) { extraTags.Add(new TagValue(kvp.Key, kvp.Value)); } } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }