Esempio n. 1
0
        public void XNamespace_returns_element_namespace_if_element_not_null()
        {
            var element                  = new XElement("{urn:tempuri}element");
            var modelManager             = new Mock <ModelManager>(null, null).Object;
            var modelProvider            = new Mock <XmlModelProvider>().Object;
            var entityDesignArtifactMock = new Mock <EntityDesignArtifact>(modelManager, new Uri("urn:dummy"), modelProvider);

            entityDesignArtifactMock.Setup(a => a.SchemaVersion).Returns(EntityFrameworkVersion.Version3);

            using (var mappingModel = new MappingModel(entityDesignArtifactMock.Object, element))
            {
                Assert.Same(element.Name.Namespace, mappingModel.XNamespace);
            }
        }
Esempio n. 2
0
        /// <summary>
        ///     Retrieve the root "mapping" node for current node.  If there is no root mapping node, this will return null.
        /// </summary>
        /// <returns></returns>
        internal static MappingModel GetMappingRoot(EFElement node)
        {
            EFContainer  currNode = node;
            MappingModel model    = null;

            while (currNode != null)
            {
                model = currNode as MappingModel;
                if (model != null)
                {
                    break;
                }
                else
                {
                    currNode = currNode.Parent;
                }
            }

            return(model);
        }
Esempio n. 3
0
        public void XNamespace_returns_root_namespace_if_element_null()
        {
            var tmpElement = new XElement("{http://schemas.microsoft.com/ado/2009/11/mapping/cs}Schema");

            var modelManager         = new Mock <ModelManager>(null, null).Object;
            var modelProvider        = new Mock <XmlModelProvider>().Object;
            var entityDesignArtifact =
                new Mock <EntityDesignArtifact>(modelManager, new Uri("urn:dummy"), modelProvider)
            {
                CallBase = true
            }.Object;

            entityDesignArtifact.SetXObject(
                XDocument.Parse("<Edmx xmlns=\"http://schemas.microsoft.com/ado/2009/11/edmx\" />"));

            using (var mappingModel = new MappingModel(entityDesignArtifact, tmpElement))
            {
                mappingModel.SetXObject(null);
                Assert.Equal("http://schemas.microsoft.com/ado/2009/11/mapping/cs", mappingModel.XNamespace);

                // resetting the element is required for clean up
                mappingModel.SetXObject(tmpElement);
            }
        }