public void Verify(IEnumerable <XElement> expectedXElements, IEnumerable <XElement> actualXElements)
        {
            Assert.AreEqual(expectedXElements.Count(), actualXElements.Count(), "Unexpected number of Csdl files!");

            var comparer = new CsdlXElementComparer();

            // extract EntityContainers into one place
            XElement expectedContainers = CsdlElementExtractor.ExtractElementByName(expectedXElements, "EntityContainer");
            XElement actualContainers   = CsdlElementExtractor.ExtractElementByName(actualXElements, "EntityContainer");

            // compare just the EntityContainers
            Console.WriteLine("Expected: " + expectedContainers.ToString());
            Console.WriteLine("Actual: " + actualContainers.ToString());
            comparer.Compare(expectedContainers, actualContainers);

            // compare non-EntityContainers
            foreach (XElement expectedXElement in expectedXElements)
            {
                string   schemaNamespace = expectedXElement.Attribute("Namespace").Value;
                XElement actualXElement  = actualXElements.FirstOrDefault(e => schemaNamespace == e.Attribute("Namespace").Value);

                Assert.IsNotNull(actualXElement, "Cannot find schema for '{0}' in result Csdls!", schemaNamespace);

                Console.WriteLine("Expected: " + expectedXElement.ToString());
                Console.WriteLine("Actual: " + actualXElement.ToString());
                comparer.Compare(expectedXElement, actualXElement);
            }
        }
Exemplo n.º 2
0
        public void Compare(List <XElement> expectXElements, List <XElement> actualXElements)
        {
            Assert.AreEqual(expectXElements.Count(), actualXElements.Count(), "Unexpected number of Csdl files!");

            // extract EntityContainers into one place
            XElement expectedContainers = CsdlElementExtractor.ExtractElementByName(expectXElements, "EntityContainer");
            XElement actualContainers   = CsdlElementExtractor.ExtractElementByName(actualXElements, "EntityContainer");

            // compare just the EntityContainers
            Console.WriteLine("Expected: " + expectedContainers.ToString());
            Console.WriteLine("Actual: " + actualContainers.ToString());
            csdlXElementComparer.Compare(expectedContainers, actualContainers);

            foreach (var expectXElement in expectXElements)
            {
                string   schemaNamespace = expectXElement.Attribute("Namespace") == null ? string.Empty : expectXElement.Attribute("Namespace").Value;
                XElement actualXElement  = actualXElements.FirstOrDefault(e => schemaNamespace == (e.Attribute("Namespace") == null ? string.Empty : e.Attribute("Namespace").Value));

                Assert.IsNotNull(actualXElement, "Cannot find schema for '{0}' in result Csdls!", schemaNamespace);

                Console.WriteLine("Expected: " + expectXElement.ToString());
                Console.WriteLine("Actual: " + actualXElement.ToString());

                csdlXElementComparer.Compare(expectXElement, actualXElement);
                // TODO: Extend the TaupoModelComparer for the Constructible APIs instead of using CsdlXElementComparer.
            }
        }