本文整理汇总了C#中Connection.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.ToString方法的具体用法?C# Connection.ToString怎么用?C# Connection.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection.ToString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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);
}
示例4: 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);
}
示例5: 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);
}
示例6: 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);
}
示例7: ToString_EmptyObject_Expected_
public void ToString_EmptyObject_Expected_()
{
Connection testConnection = new Connection();
string actualSerializedConnection = testConnection.ToString();
string expected = JsonConvert.SerializeObject(testConnection);
Assert.AreEqual(expected, actualSerializedConnection);
}
示例8: connection_TransmitEvent
/// <summary>
/// EventHandler method
/// this will triggers whenever the sender sends transmit data action
/// process web view TargetURL
/// Load Url
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void connection_TransmitEvent(object sender, Connection.Event.TransmitEventArgs e)
{
this.Invoke((MethodInvoker)delegate
{
/// Load url whenever e is not equal to TargetURL
if (string.Compare(this.WebViewControl.Source.AbsoluteUri, e.ToString(), true) != 0)
this.WebViewControl.LoadURL(e.ToString());
});
}