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


C# MockSerialConnection.MockReceiveDelayed方法代码示例

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


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

示例1: ReadLineAsync

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

            var t = session.ReadLineAsync();
            connection.MockReceiveDelayed("Test" + session.NewLine);
            
            string data = await t;
            Assert.AreEqual("Test", data);
        }
开发者ID:sandermvanvliet,项目名称:Arduino,代码行数:11,代码来源:IStringProtocolTester.cs

示例2: ReadToAsync

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

            var t = session.ReadToAsync(',');
            connection.MockReceiveDelayed("alpha,beta,gamma");

            string data = await t;
            Assert.AreEqual("alpha", data);
        }
开发者ID:sandermvanvliet,项目名称:Arduino,代码行数:11,代码来源:IStringProtocolTester.cs

示例3: ReadAsync_4Characters

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

            var t = session.ReadAsync(4);
            connection.MockReceiveDelayed("Test");

            string data = await t;
            Assert.AreEqual("Test", data);
        }
开发者ID:sandermvanvliet,项目名称:Arduino,代码行数:11,代码来源:IStringProtocolTester.cs

示例4: ReadAsync_Length_IsNegative

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

            var t = session.ReadAsync(-1);
            connection.MockReceiveDelayed("Test");

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

示例5: 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

示例6: ReadTo_EmptyString

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

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

            connection.MockReceiveDelayed(";");

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

示例7: Read_NegativeLength

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

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

            connection.MockReceiveDelayed("Hello!!!");

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

示例8: ReadLine_CarriageReturnPlusLinefeed

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

            session.NewLine = "\r\n";

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

            connection.MockReceiveDelayed("A line." + session.NewLine + "Second line." + session.NewLine);

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

示例9: Read_StringBlock

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

            var t = Task.Run(() =>
                {
                    string data = session.Read(6);
                    Assert.AreEqual("Hello!", data);
                }
            );

            connection.MockReceiveDelayed("Hello!!!");

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

示例10: RequestBufferOverflow

        //[TestMethod] // Verdacht
        public async Task RequestBufferOverflow()
        {
            var connection = new MockSerialConnection();
            var session = CreateSerialSession(connection);

            var tasks = new List<Task<string>>(100);

            for (int x = 0; x < 100; x++)
                tasks.Add(session.ReadAsync());

            Thread.Sleep(250);

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

            await Task.WhenAll(tasks);

            foreach (Task<string> t in tasks)
            {
                Assert.AreEqual("*", t.Result);
            }
        }
开发者ID:sandermvanvliet,项目名称:Arduino,代码行数:22,代码来源:IStringProtocolTester.cs

示例11: 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

示例12: StringReceived

        //[TestMethod]
        public void StringReceived()
        {
            string s = null;

            var connection = new MockSerialConnection();
            var session = CreateSerialSession(connection);
            session.NewLine = "\n";
            session.StringReceived += (o, e) =>
                {
                    s = e.Text;
                };

            connection.MockReceiveDelayed("ACME\n");
            Assert.AreEqual("ACME", s);
        }
开发者ID:sandermvanvliet,项目名称:Arduino,代码行数:16,代码来源:IStringProtocolTester.cs

示例13: Read_OneCharacter

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

            var t = Task.Run(() =>
                {
                    string data = session.Read();
                    Assert.AreEqual("Z", data);
                }
            );

            connection.MockReceiveDelayed("Zxxxx");

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


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