mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-21 15:27:55 +08:00
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();
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|