Esempio n. 1
0
        static bool FindDifferences(DDDObjectLog log1, DDDObjectLog log2, int timeToCompare)
        {
            Dictionary<string, Dictionary<string, string>> state1 = log1.GetStateAtTime(timeToCompare);
            Dictionary<string, Dictionary<string, string>> state2 = log2.GetStateAtTime(timeToCompare);

            List<string> objectsOnlyIn1 = new List<string>();
            List<string> objectsOnlyIn2 = new List<string>();
            List<string> objectsInBoth = new List<string>();

            bool foundDifferences = false;

            foreach (string key in state1.Keys)
            {
                if (state2.ContainsKey(key))
                {
                    objectsInBoth.Add(key);
                }
                else
                {
                    objectsOnlyIn1.Add(key);
                }
            }
            foreach (string key in state2.Keys)
            {
                if (!state1.ContainsKey(key))
                {
                    objectsOnlyIn2.Add(key);
                }
            }

            foreach (string s in objectsOnlyIn1)
            {
                foundDifferences = true;
                Console.WriteLine(String.Format("{0} missing in {1}", s, log2.FilePath));
            }
            foreach (string s in objectsOnlyIn2)
            {
                foundDifferences = true;
                Console.WriteLine(String.Format("{0} missing in {1}", s, log1.FilePath));
            }

            foreach (string obID in objectsInBoth)
            {
                List<string> attsOnlyIn1 = new List<string>();
                List<string> attsOnlyIn2 = new List<string>();
                List<string> attsInBoth = new List<string>();

                foreach (string key in state1[obID].Keys)
                {
                    if (state2[obID].ContainsKey(key))
                    {
                        attsInBoth.Add(key);
                    }
                    else
                    {
                        attsOnlyIn1.Add(key);
                    }
                }
                foreach (string key in state2[obID].Keys)
                {
                    if (!state1[obID].ContainsKey(key))
                    {
                        attsOnlyIn2.Add(key);
                    }
                }

                foreach (string s in attsOnlyIn1)
                {
                    foundDifferences = true;
                    Console.WriteLine(String.Format("{0}:{1} is missing in {2}", obID, s, log2.FilePath));
                }
                foreach (string s in attsOnlyIn2)
                {
                    foundDifferences = true;
                    Console.WriteLine(String.Format("{0}:{1} is missing in {2}", obID, s, log1.FilePath));
                }

                foreach (string att in attsInBoth)
                {
                    if (state1[obID][att] != state2[obID][att])
                    {
                        foundDifferences = true;
                        Console.WriteLine(String.Format("diff found for {0}:{1} {2} != {3}", obID, att, state1[obID][att], state2[obID][att]));
                    }
                }
            }
            return foundDifferences;
        }
Esempio n. 2
0
        static bool FindDifferences(DDDObjectLog log1, DDDObjectLog log2, int timeToCompare)
        {
            Dictionary <string, Dictionary <string, string> > state1 = log1.GetStateAtTime(timeToCompare);
            Dictionary <string, Dictionary <string, string> > state2 = log2.GetStateAtTime(timeToCompare);

            List <string> objectsOnlyIn1 = new List <string>();
            List <string> objectsOnlyIn2 = new List <string>();
            List <string> objectsInBoth  = new List <string>();

            bool foundDifferences = false;

            foreach (string key in state1.Keys)
            {
                if (state2.ContainsKey(key))
                {
                    objectsInBoth.Add(key);
                }
                else
                {
                    objectsOnlyIn1.Add(key);
                }
            }
            foreach (string key in state2.Keys)
            {
                if (!state1.ContainsKey(key))
                {
                    objectsOnlyIn2.Add(key);
                }
            }

            foreach (string s in objectsOnlyIn1)
            {
                foundDifferences = true;
                Console.WriteLine(String.Format("{0} missing in {1}", s, log2.FilePath));
            }
            foreach (string s in objectsOnlyIn2)
            {
                foundDifferences = true;
                Console.WriteLine(String.Format("{0} missing in {1}", s, log1.FilePath));
            }

            foreach (string obID in objectsInBoth)
            {
                List <string> attsOnlyIn1 = new List <string>();
                List <string> attsOnlyIn2 = new List <string>();
                List <string> attsInBoth  = new List <string>();

                foreach (string key in state1[obID].Keys)
                {
                    if (state2[obID].ContainsKey(key))
                    {
                        attsInBoth.Add(key);
                    }
                    else
                    {
                        attsOnlyIn1.Add(key);
                    }
                }
                foreach (string key in state2[obID].Keys)
                {
                    if (!state1[obID].ContainsKey(key))
                    {
                        attsOnlyIn2.Add(key);
                    }
                }

                foreach (string s in attsOnlyIn1)
                {
                    foundDifferences = true;
                    Console.WriteLine(String.Format("{0}:{1} is missing in {2}", obID, s, log2.FilePath));
                }
                foreach (string s in attsOnlyIn2)
                {
                    foundDifferences = true;
                    Console.WriteLine(String.Format("{0}:{1} is missing in {2}", obID, s, log1.FilePath));
                }

                foreach (string att in attsInBoth)
                {
                    if (state1[obID][att] != state2[obID][att])
                    {
                        foundDifferences = true;
                        Console.WriteLine(String.Format("diff found for {0}:{1} {2} != {3}", obID, att, state1[obID][att], state2[obID][att]));
                    }
                }
            }
            return(foundDifferences);
        }