本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
示例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;
}