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


C# Test.MockSerialConnection类代码示例

本文整理汇总了C#中Solid.Arduino.Test.MockSerialConnection的典型用法代码示例。如果您正苦于以下问题:C# MockSerialConnection类的具体用法?C# MockSerialConnection怎么用?C# MockSerialConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MockSerialConnection类属于Solid.Arduino.Test命名空间,在下文中一共展示了MockSerialConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Write

 public void Write()
 {
     var connection = new MockSerialConnection();
     var session = CreateSerialSession(connection);
     connection.EnqueueStringRequest("Test!");
     session.Write("Test!");
 }
开发者ID:sandermvanvliet,项目名称:Arduino,代码行数:7,代码来源:IStringProtocolTester.cs

示例2: ClearSession

 public void ClearSession()
 {
     var connection = new MockSerialConnection();
     var session = new ArduinoSession(connection);
     session.Clear();
     session.Dispose();
 }
开发者ID:nahueltaibo,项目名称:Arduino,代码行数:7,代码来源:ArduinoSessionTester.cs

示例3: CreateSessionWithOpenConnection

 public void CreateSessionWithOpenConnection()
 {
     var connection = new MockSerialConnection();
     connection.Open();
     var session = new ArduinoSession(connection);
     Assert.AreEqual(true, connection.IsOpen);
 }
开发者ID:nahueltaibo,项目名称:Arduino,代码行数:7,代码来源:ArduinoSessionTester.cs

示例4: TimeOutReached

 public void TimeOutReached()
 {
     var connection = new MockSerialConnection();
     var session = new ArduinoSession(connection);
     session.TimeOut = 1;
     // TODO: verder uitwerken.
 }
开发者ID:nahueltaibo,项目名称:Arduino,代码行数:7,代码来源:ArduinoSessionTester.cs

示例5: WriteI2C_SlaveAddress_Parameter_Is127

        public void WriteI2C_SlaveAddress_Parameter_Is127()
        {
            var connection = new MockSerialConnection();
            var session = CreateFirmataSession(connection);

            connection.EnqueueRequest(0xF0, 0x76, 0x7F, 0x00, 0x11, 0x00, 0x22, 0x00, 0x33, 0x00, 0x44, 0x00, 0x7F, 0x01, 0xF7);
            session.WriteI2C(127, 0x11, 0x22, 0x33, 0x44, 0xFF);
        }
开发者ID:nahueltaibo,项目名称:Arduino,代码行数:8,代码来源:I2cProtocolTester.cs

示例6: SetI2CReadInterval_Interval_Is0x3FFF

        public void SetI2CReadInterval_Interval_Is0x3FFF()
        {
            var connection = new MockSerialConnection();
            var session = CreateFirmataSession(connection);

            connection.EnqueueRequestAndResponse(new byte[] { 0xF0, 0x78, 0x7F, 0x7F, 0xF7 });
            session.SetI2CReadInterval(0x3FFF);
        }
开发者ID:nahueltaibo,项目名称:Arduino,代码行数:8,代码来源:I2cProtocolTester.cs

示例7: WriteI2C_SlaveAddress_Parameter_Is0x3FF

        public void WriteI2C_SlaveAddress_Parameter_Is0x3FF()
        {
            var connection = new MockSerialConnection();
            var session = CreateFirmataSession(connection);

            connection.EnqueueRequest(0xF0, 0x76, 0x7F, 0x27, 0x7F, 0x01, 0xF7);
            session.WriteI2C(0x3FF, 255);
        }
开发者ID:nahueltaibo,项目名称:Arduino,代码行数:8,代码来源:I2cProtocolTester.cs

示例8: ConfigureServo_MaxPulse_IsNegative

        public void ConfigureServo_MaxPulse_IsNegative()
        {
            var connection = new MockSerialConnection();
            var session = CreateServoSession(connection);

            connection.EnqueueRequestAndResponse(new byte[] { 0xF0, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF7 });
            session.ConfigureServo(15, 0, -1);
        }
开发者ID:nahueltaibo,项目名称:Arduino,代码行数:8,代码来源:IServoProtocolTester.cs

示例9: ConfigureServo_MinPulse_Is0x4000

        public void ConfigureServo_MinPulse_Is0x4000()
        {
            var connection = new MockSerialConnection();
            var session = CreateServoSession(connection);

            connection.EnqueueRequestAndResponse(new byte[] { 0xF0, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00 });
            session.ConfigureServo(0, 0x4000, 0);
        }
开发者ID:nahueltaibo,项目名称:Arduino,代码行数:8,代码来源:IServoProtocolTester.cs

示例10: ConfigureServo_PinNumber_Is128

        public void ConfigureServo_PinNumber_Is128()
        {
            var connection = new MockSerialConnection();
            var session = CreateServoSession(connection);

            connection.EnqueueRequestAndResponse(new byte[] { 0xF0, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00 });
            session.ConfigureServo(128, 0, 0);
        }
开发者ID:nahueltaibo,项目名称:Arduino,代码行数:8,代码来源:IServoProtocolTester.cs

示例11: TimeOut_GetAndSet

 public void TimeOut_GetAndSet()
 {
     var connection = new MockSerialConnection();
     var session = new ArduinoSession(connection);
     Assert.AreEqual(-1, session.TimeOut);
     session.TimeOut = 7;
     Assert.AreEqual(7, session.TimeOut);
 }
开发者ID:nahueltaibo,项目名称:Arduino,代码行数:8,代码来源:ArduinoSessionTester.cs

示例12: GetProtocolVersionAsync

        public void GetProtocolVersionAsync()
        {
            var connection = new MockSerialConnection();
            var session = CreateFirmataSession(connection);

            connection.EnqueueRequestAndResponse(new byte[] { 0xF9 }, new byte[] { 0xF9, 2, 3 });
            ProtocolVersion version = session.GetProtocolVersionAsync().Result;
            Assert.AreEqual(2, version.Major);
            Assert.AreEqual(3, version.Minor);
            Assert.AreEqual(1, _messagesReceived.Count);
        }
开发者ID:nahueltaibo,项目名称:Arduino,代码行数:11,代码来源:IFirmataProtocolTester.cs

示例13: ResetBoard

        public void ResetBoard()
        {
            var connection = new MockSerialConnection();
            var session = CreateFirmataSession(connection);

            connection.EnqueueRequestAndResponse(new byte[] { 0xFF }, new byte[] { 0xF9, 2, 3 });
            session.ResetBoard();

            Assert.AreEqual(1, _messagesReceived.Count);
            FirmataMessage message = _messagesReceived.Dequeue();
            Assert.AreEqual(MessageType.ProtocolVersion, message.Type);
            var version = (ProtocolVersion)message.Value;
            Assert.AreEqual(2, version.Major);
            Assert.AreEqual(3, version.Minor);
        }
开发者ID:nahueltaibo,项目名称:Arduino,代码行数:15,代码来源:IFirmataProtocolTester.cs

示例14: ReceivedStringBufferOverflow

        public async Task ReceivedStringBufferOverflow()
        {
            var connection = new MockSerialConnection();
            var session = CreateSerialSession(connection);

            var t = Task.Run(() =>
                {
                    string data = session.Read(1000);
                }
            );

            connection.MockReceiveDelayed(new string('*', 3000));

            await t;
        }
开发者ID:sandermvanvliet,项目名称:Arduino,代码行数:15,代码来源:IStringProtocolTester.cs

示例15: ReadTo

        public async Task ReadTo()
        {
            var connection = new MockSerialConnection();
            var session = CreateSerialSession(connection);

            var t = Task.Run(() =>
                {
                    string data = session.ReadTo('.');
                    Assert.AreEqual("A line", data);
                }
            );

            connection.MockReceiveDelayed("A line.");

            await t;
        }
开发者ID:sandermvanvliet,项目名称:Arduino,代码行数:16,代码来源:IStringProtocolTester.cs


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