mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-02 16:57:56 +08:00
63d989cab4
* Deprecate ATL based IPC wrapper library * C# projects now use named pipe server implementations from two_way_pipe_message through the interop C++/Cli library. * Added Unit testing to interop library
56 lines
1.4 KiB
C#
56 lines
1.4 KiB
C#
using System;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using System.IO.Pipes;
|
|
using interop;
|
|
using System.IO;
|
|
using System.Threading;
|
|
using System.Text;
|
|
|
|
namespace interop_tests
|
|
{
|
|
[TestClass]
|
|
public class UnitTest1
|
|
{
|
|
private string SERVER_SIDE = "\\\\.\\pipe\\serverside";
|
|
private string CLIENT_SIDE = "\\\\.\\pipe\\clientside";
|
|
|
|
private TwoWayPipeMessageIPCManaged clientPipe;
|
|
|
|
[TestInitialize]
|
|
public void Initialize()
|
|
{
|
|
clientPipe = new TwoWayPipeMessageIPCManaged(CLIENT_SIDE, SERVER_SIDE, null);
|
|
}
|
|
|
|
[TestCleanup]
|
|
public void Cleanup()
|
|
{
|
|
clientPipe.End();
|
|
}
|
|
|
|
[TestMethod]
|
|
public void TestSend()
|
|
{
|
|
var testString = "This string is a test\n";
|
|
var reset = new AutoResetEvent(false);
|
|
|
|
var serverPipe = new TwoWayPipeMessageIPCManaged(
|
|
SERVER_SIDE,
|
|
CLIENT_SIDE,
|
|
(string msg) =>
|
|
{
|
|
Assert.AreEqual(testString, msg);
|
|
reset.Set();
|
|
});
|
|
serverPipe.Start();
|
|
clientPipe.Start();
|
|
|
|
clientPipe.Send(testString);
|
|
reset.WaitOne();
|
|
|
|
serverPipe.End();
|
|
}
|
|
|
|
}
|
|
}
|