本文整理汇总了C#中Connection.SendCommand方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.SendCommand方法的具体用法?C# Connection.SendCommand怎么用?C# Connection.SendCommand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection.SendCommand方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendCommandWhitespaceTest
public void SendCommandWhitespaceTest()
{
using (var connection = new Connection(CreateClientFactory()))
{
Connect(connection);
bool statusMessageFired = false;
connection.StatusMessage += (sender, args) => statusMessageFired = true;
connection.SendCommand(" ");
Assert.IsTrue(statusMessageFired);
}
_tcpClient.VerifyAllExpectations();
_stream.VerifyAllExpectations();
}
示例2: SendCommandTest3
public void SendCommandTest3()
{
using (var connection = new Connection(CreateClientFactory()))
{
Connect(connection);
bool dataLengthSentFired = false;
bool statusMessageFired = false;
bool connectedChangedFired = false;
connection.DataLengthSent += (sender, args) => dataLengthSentFired = true;
connection.StatusMessage += (sender, args) => statusMessageFired = true;
connection.ConnectedChanged += (sender, args) => connectedChangedFired = true;
var buffer = Encoding.ASCII.GetBytes("command\n");
_stream.Expect(x => x.Write(buffer, 0, buffer.Length)).Throw(new IOException("Write failed."));
connection.SendCommand("command");
Assert.IsFalse(dataLengthSentFired);
Assert.IsTrue(statusMessageFired);
Assert.IsTrue(connectedChangedFired);
}
_tcpClient.VerifyAllExpectations();
_stream.VerifyAllExpectations();
}
示例3: SendCommandTest1
public void SendCommandTest1()
{
using (var connection = new Connection(CreateClientFactory()))
{
connection.SendCommand("command");
}
}
示例4: Connection_SendCommand_Test3
public void Connection_SendCommand_Test3()
{
using (var connection = new Connection(CreateClientFactory()))
{
Connect(connection);
var mre = new ManualResetEvent(false);
bool dataSentFired = false;
bool statusMessageFired = false;
bool connectedChangedFired = false;
connection.DataSent += (sender, args) => dataSentFired = true;
connection.StatusMessage += (sender, args) =>
{
statusMessageFired = true;
mre.Set();
};
connection.ConnectedChanged += (sender, args) => connectedChangedFired = true;
_stream.Expect(x => x.EndWrite(null)).IgnoreArguments().Throw(new IOException("Write failed."));
_tcpClient.Expect(x => x.Close()).Do(new Action(() => _tcpClient.Client = null));
connection.SendCommand("command");
mre.WaitOne();
Assert.IsFalse(dataSentFired);
Assert.IsTrue(statusMessageFired);
Assert.IsTrue(connectedChangedFired);
}
_tcpClient.VerifyAllExpectations();
_stream.VerifyAllExpectations();
}
示例5: Connection_SendCommand_Test2
public void Connection_SendCommand_Test2()
{
using (var connection = new Connection(CreateClientFactory()))
{
Connect(connection);
var mre = new ManualResetEvent(false);
bool dataSentFired = false;
bool statusMessageFired = false;
connection.DataSent += (sender, args) =>
{
dataSentFired = true;
mre.Set();
};
connection.StatusMessage += (sender, args) => statusMessageFired = true;
connection.SendCommand("command");
mre.WaitOne();
Assert.IsTrue(dataSentFired);
Assert.IsTrue(statusMessageFired);
}
_tcpClient.VerifyAllExpectations();
_stream.VerifyAllExpectations();
}
示例6: Connection_SendCommand_Test1
public void Connection_SendCommand_Test1()
{
using (var connection = new Connection(CreateClientFactory()))
{
Assert.Throws<InvalidOperationException>(() => connection.SendCommand("command"));
}
}