mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 03:37:59 +01:00
Getting FxCop online (#6668)
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using interop;
|
using interop;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
@@ -9,46 +10,73 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|||||||
namespace Microsoft.Interop.Tests
|
namespace Microsoft.Interop.Tests
|
||||||
{
|
{
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class InteropTests
|
public class InteropTests : IDisposable
|
||||||
{
|
{
|
||||||
private const string ServerSidePipe = "\\\\.\\pipe\\serverside";
|
private const string ServerSidePipe = "\\\\.\\pipe\\serverside";
|
||||||
private const string ClientSidePipe = "\\\\.\\pipe\\clientside";
|
private const string ClientSidePipe = "\\\\.\\pipe\\clientside";
|
||||||
|
|
||||||
private TwoWayPipeMessageIPCManaged clientPipe;
|
internal TwoWayPipeMessageIPCManaged ClientPipe { get; set; }
|
||||||
|
|
||||||
|
private bool disposedValue;
|
||||||
|
|
||||||
[TestInitialize]
|
[TestInitialize]
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
clientPipe = new TwoWayPipeMessageIPCManaged(ClientSidePipe, ServerSidePipe, null);
|
ClientPipe = new TwoWayPipeMessageIPCManaged(ClientSidePipe, ServerSidePipe, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCleanup]
|
[TestCleanup]
|
||||||
public void Cleanup()
|
public void Cleanup()
|
||||||
{
|
{
|
||||||
clientPipe.End();
|
ClientPipe.End();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestSend()
|
public void TestSend()
|
||||||
{
|
{
|
||||||
var testString = "This string is a test\n";
|
var testString = "This string is a test\n";
|
||||||
var reset = new AutoResetEvent(false);
|
using (var reset = new AutoResetEvent(false))
|
||||||
|
{
|
||||||
var serverPipe = new TwoWayPipeMessageIPCManaged(
|
using (var serverPipe = new TwoWayPipeMessageIPCManaged(
|
||||||
ServerSidePipe,
|
ServerSidePipe,
|
||||||
ClientSidePipe,
|
ClientSidePipe,
|
||||||
(string msg) =>
|
(string msg) =>
|
||||||
|
{
|
||||||
|
Assert.AreEqual(testString, msg);
|
||||||
|
reset.Set();
|
||||||
|
}))
|
||||||
{
|
{
|
||||||
Assert.AreEqual(testString, msg);
|
serverPipe.Start();
|
||||||
reset.Set();
|
ClientPipe.Start();
|
||||||
});
|
|
||||||
serverPipe.Start();
|
|
||||||
clientPipe.Start();
|
|
||||||
|
|
||||||
clientPipe.Send(testString);
|
ClientPipe.Send(testString);
|
||||||
reset.WaitOne();
|
reset.WaitOne();
|
||||||
|
|
||||||
serverPipe.End();
|
serverPipe.End();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (!disposedValue)
|
||||||
|
{
|
||||||
|
if (disposing)
|
||||||
|
{
|
||||||
|
ClientPipe.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: free unmanaged resources (unmanaged objects) and override finalizer
|
||||||
|
// TODO: set large fields to null
|
||||||
|
disposedValue = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
||||||
|
Dispose(disposing: true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,6 @@
|
|||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@@ -107,6 +106,11 @@
|
|||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers">
|
||||||
|
<Version>3.3.0</Version>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="StyleCop.Analyzers">
|
<PackageReference Include="StyleCop.Analyzers">
|
||||||
<Version>1.1.118</Version>
|
<Version>1.1.118</Version>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
|||||||
Reference in New Issue
Block a user