From a46103fc8ccdf115f97d97e3bad7c7d3b921c1e1 Mon Sep 17 00:00:00 2001 From: Clint Rutkas Date: Thu, 30 Jul 2020 12:22:33 -0700 Subject: [PATCH] Adjusting interop tests for 5295 (#5296) Co-authored-by: Clint Rutkas --- PowerToys.sln | 2 +- .../{UnitTest1.cs => InteropTests.cs} | 109 ++++---- ....csproj => Microsoft.Interop.Tests.csproj} | 235 +++++++++--------- 3 files changed, 179 insertions(+), 167 deletions(-) rename src/common/interop-tests/{UnitTest1.cs => InteropTests.cs} (62%) rename src/common/interop-tests/{interop-tests.csproj => Microsoft.Interop.Tests.csproj} (91%) diff --git a/PowerToys.sln b/PowerToys.sln index eb45d5b047..d2b3b290c4 100644 --- a/PowerToys.sln +++ b/PowerToys.sln @@ -239,7 +239,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "interop", "src\common\inter EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common-md-flag", "src\common\common-md-flag\common-md-flag.vcxproj", "{985B3F2F-CEED-4C0A-A249-69257E719145}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "interop-tests", "src\common\interop-tests\interop-tests.csproj", "{437AD818-3F1F-4CA5-A79B-25233A157026}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Interop.Tests", "src\common\interop-tests\Microsoft.Interop.Tests.csproj", "{437AD818-3F1F-4CA5-A79B-25233A157026}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Plugin.Folder", "src\modules\launcher\Plugins\Microsoft.Plugin.Folder\Microsoft.Plugin.Folder.csproj", "{787B8AA6-CA93-4C84-96FE-DF31110AD1C4}" EndProject diff --git a/src/common/interop-tests/UnitTest1.cs b/src/common/interop-tests/InteropTests.cs similarity index 62% rename from src/common/interop-tests/UnitTest1.cs rename to src/common/interop-tests/InteropTests.cs index 283fb2d40c..d1bf8c4aed 100644 --- a/src/common/interop-tests/UnitTest1.cs +++ b/src/common/interop-tests/InteropTests.cs @@ -1,55 +1,54 @@ -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(); - } - - } -} +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Threading; +using interop; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Microsoft.Interop.Tests +{ + [TestClass] + public class InteropTests + { + private const string ServerSidePipe = "\\\\.\\pipe\\serverside"; + private const string ClientSidePipe = "\\\\.\\pipe\\clientside"; + + private TwoWayPipeMessageIPCManaged clientPipe; + + [TestInitialize] + public void Initialize() + { + clientPipe = new TwoWayPipeMessageIPCManaged(ClientSidePipe, ServerSidePipe, 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( + ServerSidePipe, + ClientSidePipe, + (string msg) => + { + Assert.AreEqual(testString, msg); + reset.Set(); + }); + serverPipe.Start(); + clientPipe.Start(); + + clientPipe.Send(testString); + reset.WaitOne(); + + serverPipe.End(); + } + } +} diff --git a/src/common/interop-tests/interop-tests.csproj b/src/common/interop-tests/Microsoft.Interop.Tests.csproj similarity index 91% rename from src/common/interop-tests/interop-tests.csproj rename to src/common/interop-tests/Microsoft.Interop.Tests.csproj index 438a102a28..64d56eb54e 100644 --- a/src/common/interop-tests/interop-tests.csproj +++ b/src/common/interop-tests/Microsoft.Interop.Tests.csproj @@ -1,112 +1,125 @@ - - - - - - - - interop-tests - Microsoft Corp. - Copyright (C) 2020 Microsoft Corp. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Debug - AnyCPU - {437AD818-3F1F-4CA5-A79B-25233A157026} - Library - Properties - interop_tests - interop-tests - v4.7.2 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 15.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - - - - true - bin\x64\Debug\ - DEBUG;TRACE - full - x64 - 7.3 - prompt - MinimumRecommendedRules.ruleset - - - bin\x64\Release\ - TRACE - true - pdbonly - x64 - 7.3 - prompt - MinimumRecommendedRules.ruleset - - - - ..\..\..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll - - - ..\..\..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll - - - - - - - - Code - - - - - - - - {f055103b-f80b-4d0c-bf48-057c55620033} - interop - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - + + + + + + + + interop-tests + Microsoft Corp. + Copyright (C) 2020 Microsoft Corp. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Debug + AnyCPU + {437AD818-3F1F-4CA5-A79B-25233A157026} + Library + Properties + Microsoft.Interop.Tests + Microsoft.Interop.Tests + v4.7.2 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + 7.3 + prompt + MinimumRecommendedRules.ruleset + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + 7.3 + prompt + MinimumRecommendedRules.ruleset + + + + ..\..\..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\..\..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + + + + + GlobalSuppressions.cs + + + + Code + + + + + StyleCop.json + + + + + + 1.1.118 + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + {f055103b-f80b-4d0c-bf48-057c55620033} + interop + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file