当前位置: 首页>>代码示例>>C#>>正文


C# Connection.ToXml方法代码示例

本文整理汇总了C#中Connection.ToXml方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.ToXml方法的具体用法?C# Connection.ToXml怎么用?C# Connection.ToXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Connection的用法示例。


在下文中一共展示了Connection.ToXml方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConnectionExplicitConverting

        public void ConnectionExplicitConverting()
        {
            var conn = new Connection("UM", ".", "UsersManagements");

            string connStr = (string)conn;
            XElement connXml = (XElement)conn;

            Assert.AreEqual(connStr, conn.ConnectionString);
            Assert.AreEqual(connXml.ToString(SaveOptions.None), conn.ToXml().ToString(SaveOptions.None));
        }
开发者ID:eric-seekas,项目名称:ErrorControlSystem,代码行数:10,代码来源:UnitTest.cs

示例2: ConnectionImplicitConverting

        public void ConnectionImplicitConverting()
        {
            var conn = new Connection("UM", ".", "UsersManagements");

            var connStr = (Connection)conn.ConnectionString;
            var connXml = (Connection)conn.ToXml();

            Assert.AreEqual(connStr.ConnectionString, conn.ConnectionString);
            Assert.AreEqual(connXml.ConnectionString, conn.ConnectionString);
        }
开发者ID:eric-seekas,项目名称:ErrorControlSystem,代码行数:10,代码来源:UnitTest.cs

示例3: CreateConnection1Args

        public void CreateConnection1Args()
        {
            //
            // --------------- Constructor 1 Arguments ------------------------------------------
            //
            var connFull = new Connection(".", "UsersManagements", "um");
            var conn = new Connection(connFull);

            Assert.AreEqual(conn.ToXml(false).ToString(SaveOptions.None), conn.ToString());
            Assert.AreEqual(conn.ToXml(true).ToString(SaveOptions.None), conn.ToString(true));
            var newConnWithoutId = conn.ToXml(true);
            TestTools.ExceptException<NullReferenceException>(() => newConnWithoutId.Element("add").Attribute("publicKeyToken").Value = "");
            var c = Connection.Parse(newConnWithoutId);
            Assert.AreEqual(c.ConnectionString, conn.ConnectionString); // c.Id != conn.Id but both of them have duplicate connectionString

            var conn2 = new Connection(conn.ConnectionString);

            TestTools.ExpectException<NullReferenceException>(() => conn.ConnectionString = null); // Test throw NullReferenceException

            Assert.AreEqual(conn.ConnectionString, conn2.ConnectionString);
        }
开发者ID:eric-seekas,项目名称:ErrorControlSystem,代码行数:21,代码来源:UnitTest.cs

示例4: CreateConnection2Args

        public void CreateConnection2Args()
        {
            //
            // --------------- Constructor 2 Arguments ------------------------------------------
            //
            var connFull = new Connection(".", "UsersManagements", "sa", "123", 3, "Test Connection", "um");
            var conn = new Connection(connFull.ConnectionString);

            Assert.AreEqual(conn.ToXml(false).ToString(SaveOptions.None), conn.ToString());
            Assert.AreEqual(conn.ToXml(true).ToString(SaveOptions.None), conn.ToString(true));
            Assert.AreEqual(
                Connection.Parse(conn.ToXml(true)).ConnectionString,
                conn.ConnectionString);

            var conn2 = new Connection(conn.ConnectionString);

            Assert.AreEqual(conn.ConnectionString, conn2.ConnectionString);
        }
开发者ID:eric-seekas,项目名称:ErrorControlSystem,代码行数:18,代码来源:UnitTest.cs

示例5: CreateConnection8Args

        public void CreateConnection8Args()
        {
            //
            // --------------- Constructor 8 Arguments ------------------------------------------
            //
            var conn3 = new Connection(".", "UsersManagements", "sa", "123", 3, "Test Connection", "name");

            Assert.AreEqual(conn3.ToXml(false).ToString(SaveOptions.None), conn3.ToString());
            Assert.AreEqual(conn3.ToXml(true).ToString(SaveOptions.None), conn3.ToString(true));
            Assert.AreEqual(
                Connection.Parse(conn3.ToXml(true)).ConnectionString,
                conn3.ConnectionString);

            var conn3_2 = new Connection()
            {
                ConnectionString = conn3.ConnectionString
            };

            Assert.AreEqual(conn3.ConnectionString, conn3_2.ConnectionString);
        }
开发者ID:eric-seekas,项目名称:ErrorControlSystem,代码行数:20,代码来源:UnitTest.cs

示例6: CreateConnection6Args

        public void CreateConnection6Args()
        {
            //
            // --------------- Constructor 6 Arguments ------------------------------------------
            //
            var conn2 = new Connection(".", "UsersManagements", "sa", "123", -3);

            Assert.AreEqual(conn2.ToXml().ToString(SaveOptions.None), conn2.ToString());
            Assert.AreEqual(conn2.ToXml(true).ToString(SaveOptions.None), conn2.ToString(true));
            Assert.AreEqual(
                Connection.Parse(conn2.ToXml(true)).ConnectionString,
                conn2.ConnectionString);

            var conn2_2 = new Connection()
            {
                ConnectionString = conn2.ConnectionString
            };

            Assert.AreEqual(conn2.ConnectionString, conn2_2.ConnectionString);
        }
开发者ID:eric-seekas,项目名称:ErrorControlSystem,代码行数:20,代码来源:UnitTest.cs

示例7: CreateConnection4Args

        public void CreateConnection4Args()
        {
            //
            // --------------- Constructor 4 Arguments ------------------------------------------
            //
            var conn = new Connection();

            Assert.AreEqual(conn.ToXml().ToString(SaveOptions.None), conn.ToString());
            Assert.AreEqual(conn.ToXml(true).ToString(SaveOptions.None), conn.ToString(true));
            Assert.AreEqual(
                Connection.Parse(conn.ToXml(true)).ConnectionString,
                conn.ConnectionString);

            var conn1_2 = new Connection()
            {
                ConnectionString = conn.ConnectionString
            };

            Assert.AreEqual(conn.ConnectionString, conn1_2.ConnectionString);
        }
开发者ID:eric-seekas,项目名称:ErrorControlSystem,代码行数:20,代码来源:UnitTest.cs

示例8: CreateConnection3Args

 public void CreateConnection3Args()
 {
     //
     // --------------- Constructor 3 Arguments ------------------------------------------
     //
     var conn1 = new Connection(".", "UsersManagements");
     conn1.Name = "UM";
     Assert.AreEqual(conn1.ToXml().ToString(SaveOptions.None), conn1.ToString());
     Assert.AreEqual(conn1.ToXml(true).ToString(SaveOptions.None), conn1.ToString(true));
     Assert.AreEqual(
         Connection.Parse(conn1.ToXml(true)).ConnectionString,
         conn1.ConnectionString);
 }
开发者ID:eric-seekas,项目名称:ErrorControlSystem,代码行数:13,代码来源:UnitTest.cs

示例9: ToXml_EmptyObject_Expected_XElementContainingNoInformationRegardingSource

        public void ToXml_EmptyObject_Expected_XElementContainingNoInformationRegardingSource()
        {
            Connection testConnection = new Connection();
            XElement expectedXml = testConnection.ToXml();

            IEnumerable<XAttribute> attrib = expectedXml.Attributes();
            IEnumerator<XAttribute> attribEnum = attrib.GetEnumerator();
            while(attribEnum.MoveNext())
            {
                if(attribEnum.Current.Name == "Name")
                {
                    Assert.AreEqual(string.Empty, attribEnum.Current.Value);
                    break;
                }
            }
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:16,代码来源:ConnectionTests.cs


注:本文中的Connection.ToXml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。