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


C# Connection.SendCommand方法代码示例

本文整理汇总了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();
        }
开发者ID:kszysiu,项目名称:hfm-net,代码行数:16,代码来源:ConnectionTests.cs

示例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();
        }
开发者ID:kszysiu,项目名称:hfm-net,代码行数:24,代码来源:ConnectionTests.cs

示例3: SendCommandTest1

 public void SendCommandTest1()
 {
     using (var connection = new Connection(CreateClientFactory()))
      {
     connection.SendCommand("command");
      }
 }
开发者ID:kszysiu,项目名称:hfm-net,代码行数:7,代码来源:ConnectionTests.cs

示例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();
      }
开发者ID:harlam357,项目名称:hfm-net,代码行数:33,代码来源:ConnectionTests.cs

示例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();
      }
开发者ID:harlam357,项目名称:hfm-net,代码行数:27,代码来源:ConnectionTests.cs

示例6: Connection_SendCommand_Test1

 public void Connection_SendCommand_Test1()
 {
    using (var connection = new Connection(CreateClientFactory()))
    {
       Assert.Throws<InvalidOperationException>(() => connection.SendCommand("command"));
    }
 }
开发者ID:harlam357,项目名称:hfm-net,代码行数:7,代码来源:ConnectionTests.cs


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