/// <summary>
        /// Gets the table name which should match the main XML element which
        /// is the child of ROOT.
        /// </summary>
        /// <param name="xmlFile">The xml data file path.</param>
        /// <returns>The table name, without the schema name.</returns>
        public virtual DbObjectName GetTableNameFromXmlElement(IScriptFile xmlFile)
        {
            Debug.Assert(xmlFile != null);

            if (!fileSystem.Exists(xmlFile.Path))
            {
                throw new SqlMigrationException(
                          string.Format(
                              "Could not find the XML data file {0}",
                              xmlFile.Path));
            }

            using (Stream content = xmlFile.GetContentStream())
            {
                XPathDocument  doc  = new XPathDocument(content);
                XPathNavigator navi = doc.CreateNavigator();

                navi.MoveToRoot();
                if (!navi.MoveToFirstChild()) // ROOT
                {
                    throw new SqlMigrationException(
                              "XML document is empty.  Could not find ROOT element.");
                }
                if (!navi.MoveToFirstChild()) // Table
                {
                    throw new SqlMigrationException(
                              "XML document contains no table data.  Could not find table element.");
                }

                string elem = navi.LocalName;
                elem = elem.Replace("<", "").Replace(">", "").Trim();
                return(elem);
            }
        }
        public void ShouldGetTableName()
        {
            SetupResult.For(fileSystem.Exists(null)).Return(true).IgnoreArguments();

            string       xmlDoc  = "<ROOT><Customer><CustomerID>1</CustomerID></Customer></ROOT>";
            MemoryStream content = new MemoryStream(UTF8Encoding.UTF8.GetBytes(xmlDoc));

            SetupResult.For(scriptFile.IsXml).Return(true);
            SetupResult.For(scriptFile.GetContentStream()).Return(content);

            mocks.ReplayAll();

            string tableName = executor.GetTableNameFromXmlElement(scriptFile);

            Assert.AreEqual("Customer", tableName);
        }