Esempio n. 1
0
        private static void listSchemaMetadataDiffBreakdown(SchemaEntry e1, SchemaEntry e2)
        {
            SchemaComparableList <AttributeMetadata> mdList1 = null;
            SchemaComparableList <AttributeMetadata> mdList2 = null;

            if (e1 != null && e2 != null)
            {
                mdList1 = e1.GetMetadataList();
                mdList2 = e2.GetMetadataList();

                TupleList <AttributeMetadata, AttributeMetadata> diff = mdList1.GetDiff(mdList2);

                Console.WriteLine("\tBASE: {0}", e1.defName);
                foreach (Tuple <AttributeMetadata, AttributeMetadata> t in diff)
                {
                    Console.WriteLine("\t\t{0}", t.Item1);
                }

                Console.WriteLine("\tOTHE: {0}", e2.defName);
                foreach (Tuple <AttributeMetadata, AttributeMetadata> t in diff)
                {
                    Console.WriteLine("\t\t{0}", t.Item2);
                }
            }
            else if (e1 != null)
            {
                mdList1 = e1.GetMetadataList();

                Console.WriteLine("\tBASE: {0}", e1.defName);
                foreach (AttributeMetadata md in mdList1)
                {
                    Console.WriteLine("\t\t{0}", md);
                }
                Console.WriteLine("\tOTHE:");
            }
            else
            {
                mdList2 = e2.GetMetadataList();

                Console.WriteLine("\tBASE:");
                Console.WriteLine("\tOTHE: {0}", e2.defName);
                foreach (AttributeMetadata md in mdList2)
                {
                    Console.WriteLine("\t\t{0}", md);
                }
            }

            Console.WriteLine("\t-----");
        }
        private void listSchemaMetadataDiffBreakdown(SchemaEntry e1, SchemaEntry e2)
        {
            SchemaComparableList <AttributeMetadata> mdList1 = null;
            SchemaComparableList <AttributeMetadata> mdList2 = null;

            if (e1 != null && e2 != null)
            {
                mdList1 = e1.GetMetadataList();
                mdList2 = e2.GetMetadataList();

                VmDirInterop.Schema.Utils.TupleList <AttributeMetadata, AttributeMetadata> diff = mdList1.GetDiff(mdList2);

                foreach (VmDirInterop.Schema.Utils.Tuple <AttributeMetadata, AttributeMetadata> t in diff)
                {
                    //baseMetaData
                    string baseData    = (t.item1 != null) ? e1.defName + " : " + t.item1.ToString() : VMDirSchemaConstants.MISING_METADATA;
                    string currentData = (t.item2 != null) ? e1.defName + " : " + t.item2.ToString() : VMDirSchemaConstants.MISING_METADATA;
                    MetaDataDiff.Add(new KeyValuePair <string, string>(baseData, currentData));
                }
            }
            else if (e1 != null)
            {
                mdList1 = e1.GetMetadataList();
                foreach (AttributeMetadata md in mdList1)
                {
                    string baseData    = e1.defName + " : " + md;
                    string currentData = VMDirSchemaConstants.MISING_METADATA;
                    MetaDataDiff.Add(new KeyValuePair <string, string>(baseData, currentData));
                }
            }
            else
            {
                mdList2 = e2.GetMetadataList();
                foreach (AttributeMetadata md in mdList2)
                {
                    string currentData = e1.defName + " : " + md;
                    string baseData    = VMDirSchemaConstants.MISING_METADATA;
                    MetaDataDiff.Add(new KeyValuePair <string, string>(baseData, currentData));
                }
            }
        }
        private void AssertAreSchemaEntriesEqual(
            TupleList <SchemaEntry, SchemaEntry> expectedDiff,
            TupleList <SchemaEntry, SchemaEntry> actualDiff
            )
        {
            Assert.AreEqual(expectedDiff.Count, actualDiff.Count);
            for (int i = 0; i < expectedDiff.Count; i++)
            {
                SchemaEntry expected1 = expectedDiff[i].item1;
                SchemaEntry expected2 = expectedDiff[i].item2;
                SchemaEntry actual1   = actualDiff[i].item1;
                SchemaEntry actual2   = actualDiff[i].item2;

                if (expected1 != null && expected2 != null)
                {
                    TupleList <AttributeMetadata, AttributeMetadata> expectedMdDiff =
                        expected1.GetMetadataList().GetDiff(expected2.GetMetadataList());
                    TupleList <AttributeMetadata, AttributeMetadata> actualMdDiff =
                        actual1.GetMetadataList().GetDiff(actual2.GetMetadataList());

                    AssertAreMetadataEqual(expectedMdDiff, actualMdDiff);
                }
                else if (expected1 == null)
                {
                    Assert.IsNull(actual1);
                }
                else if (expected2 == null)
                {
                    Assert.IsNull(actual2);
                }
                else
                {
                    Assert.Fail();  // they both can't be null
                }
            }
        }