Fixed tester project
This commit is contained in:
parent
f7a200c8b2
commit
819f527663
@ -17,9 +17,10 @@
|
|||||||
<PackageIconUrl />
|
<PackageIconUrl />
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Properties\" />
|
<Compile Remove="Properties\**" />
|
||||||
|
<EmbeddedResource Remove="Properties\**" />
|
||||||
|
<None Remove="Properties\**" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO.Ports;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using Nefarius.Peripherals.SerialPort;
|
||||||
|
|
||||||
namespace PInvokeSerialPort.Test
|
namespace PInvokeSerialPort.Test
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Test class.
|
/// Test class.
|
||||||
/// Attention: Run it just in test debug.
|
/// Attention: Run it just in test debug.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class PInvokeSerialPortTest
|
public class PInvokeSerialPortTest
|
||||||
{
|
{
|
||||||
dynamic _sender;
|
private dynamic _reciever;
|
||||||
dynamic _reciever;
|
private dynamic _sender;
|
||||||
StringBuilder _stringBuilder;
|
private StringBuilder _stringBuilder;
|
||||||
|
|
||||||
public void OpenWriteDoWaitClose(Action action)
|
public void OpenWriteDoWaitClose(Action action)
|
||||||
{
|
{
|
||||||
@ -40,9 +40,9 @@ namespace PInvokeSerialPort.Test
|
|||||||
_sender = new SerialPort("com1");
|
_sender = new SerialPort("com1");
|
||||||
_reciever = new SerialPort("com2");
|
_reciever = new SerialPort("com2");
|
||||||
OpenWriteDoWaitClose(() =>
|
OpenWriteDoWaitClose(() =>
|
||||||
{
|
{
|
||||||
((SerialPort)_reciever).DataReceived += x => _stringBuilder.Append((char)x);
|
((SerialPort)_reciever).DataReceived += x => _stringBuilder.Append((char)x);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -53,9 +53,9 @@ namespace PInvokeSerialPort.Test
|
|||||||
_reciever = new SerialPort("com2");
|
_reciever = new SerialPort("com2");
|
||||||
|
|
||||||
OpenWriteDoWaitClose(() =>
|
OpenWriteDoWaitClose(() =>
|
||||||
{
|
{
|
||||||
((SerialPort)(object)_reciever).DataReceived += x => _stringBuilder.Append((char)x);
|
((SerialPort)(object)_reciever).DataReceived += x => _stringBuilder.Append((char)x);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -65,9 +65,10 @@ namespace PInvokeSerialPort.Test
|
|||||||
_reciever = new System.IO.Ports.SerialPort("com2");
|
_reciever = new System.IO.Ports.SerialPort("com2");
|
||||||
|
|
||||||
OpenWriteDoWaitClose(() =>
|
OpenWriteDoWaitClose(() =>
|
||||||
{
|
{
|
||||||
((System.IO.Ports.SerialPort)_reciever).DataReceived += (x, y) => _stringBuilder.Append(_reciever.ReadExisting());
|
((System.IO.Ports.SerialPort)_reciever).DataReceived +=
|
||||||
});
|
(x, y) => _stringBuilder.Append(_reciever.ReadExisting());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -77,9 +78,10 @@ namespace PInvokeSerialPort.Test
|
|||||||
_reciever = new System.IO.Ports.SerialPort("com2");
|
_reciever = new System.IO.Ports.SerialPort("com2");
|
||||||
|
|
||||||
OpenWriteDoWaitClose(() =>
|
OpenWriteDoWaitClose(() =>
|
||||||
{
|
{
|
||||||
((System.IO.Ports.SerialPort)_reciever).DataReceived += (x, y) => _stringBuilder.Append(_reciever.ReadExisting());
|
((System.IO.Ports.SerialPort)_reciever).DataReceived +=
|
||||||
});
|
(x, y) => _stringBuilder.Append(_reciever.ReadExisting());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user