private static EdmModelCsdlSchemaWriter CreateEdmModelCsdlSchemaWriter(out XmlWriter xmlWriter, out MemoryStream memoryStream)
 {
     memoryStream = new MemoryStream();
     IEdmModel model = new EdmModel();
     model.SetEdmxVersion(new Version(4, 0));
     var namespaceAliasMappings = model.GetNamespaceAliases();
     Version edmxVersion = model.GetEdmxVersion();
     xmlWriter = XmlWriter.Create(memoryStream);
     return new EdmModelCsdlSchemaWriter(model, namespaceAliasMappings, xmlWriter, edmxVersion);
 }
Пример #2
0
 public void EdmxRoundTripTestsEmptyConceptualModelsModel()
 {
     var model = new EdmModel();
     model.SetEdmxVersion(EdmConstants.EdmVersion4);
     this.EdmxRoundTripCheck(EdmxModelBuilder.EmptyConceptualModelsEdmx(), EdmxTarget.EntityFramework, model);
 }
Пример #3
0
 public void EdmxRoundTripTestsEmptyDataServicesModel()
 {
     var model = new EdmModel();
     model.SetEdmxVersion(EdmConstants.EdmVersion4);
     this.EdmxRoundTripCheck(EdmxModelBuilder.EmptyDataServicesEdmx(), EdmxTarget.OData, model);
 }
        internal void VisitAndVerifyXml(Action<EdmModelCsdlSerializationVisitor> testAction, string expected)
        {
            XmlWriter xmlWriter;
            MemoryStream memStream;
            IEdmModel model = new EdmModel();

            model.SetEdmxVersion(new Version(4, 0));
            Version edmxVersion = model.GetEdmxVersion();
            memStream = new MemoryStream();
            xmlWriter = XmlWriter.Create(memStream, new XmlWriterSettings(){ConformanceLevel = ConformanceLevel.Auto});
            var visitor = new EdmModelCsdlSerializationVisitor(model, xmlWriter, edmxVersion);

            testAction(visitor);
            xmlWriter.Flush();
            memStream.Seek(0, SeekOrigin.Begin);
            StreamReader reader = new StreamReader(memStream);
            
            // Remove extra xml header text as its not needed.
            string result = reader.ReadToEnd().Replace(@"<?xml version=""1.0"" encoding=""utf-8""?>", string.Empty);
            Assert.AreEqual(expected, result);
        }