mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 18:26:39 +02:00
[stylecop] program plugin/unit test first pass (#5908)
* initial pass * multiple whitespace fixes
This commit is contained in:
@@ -46,5 +46,19 @@
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<!--<ItemGroup>
|
||||
<Compile Include="..\..\..\..\codeAnalysis\GlobalSuppressions.cs">
|
||||
<Link>GlobalSuppressions.cs</Link>
|
||||
</Compile>
|
||||
<AdditionalFiles Include="..\..\..\..\codeAnalysis\StyleCop.json">
|
||||
<Link>StyleCop.json</Link>
|
||||
</AdditionalFiles>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="StyleCop.Analyzers">
|
||||
<Version>1.1.118</Version>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>-->
|
||||
</Project>
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
using Castle.Core.Internal;
|
||||
// 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.Collections.Generic;
|
||||
using Castle.Core.Internal;
|
||||
using Microsoft.Plugin.Program.Programs;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Plugin.Program.UnitTests.Programs
|
||||
{
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Plugin;
|
||||
|
||||
using Microsoft.Plugin.Program;
|
||||
using System.IO.Packaging;
|
||||
using Windows.ApplicationModel;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Plugin.Program.UnitTests.Programs
|
||||
{
|
||||
using Win32Program = Microsoft.Plugin.Program.Programs.Win32Program;
|
||||
@@ -23,7 +23,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
||||
ExecutableName = "notepad.exe",
|
||||
FullPath = "c:\\windows\\system32\\notepad.exe",
|
||||
LnkResolvedPath = "c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\accessories\\notepad.lnk",
|
||||
AppType = 2
|
||||
AppType = 2,
|
||||
};
|
||||
|
||||
static Win32Program notepad_users = new Win32Program
|
||||
@@ -32,7 +32,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
||||
ExecutableName = "notepad.exe",
|
||||
FullPath = "c:\\windows\\system32\\notepad.exe",
|
||||
LnkResolvedPath = "c:\\programdata\\microsoft\\windows\\start menu\\programs\\accessories\\notepad.lnk",
|
||||
AppType = 2
|
||||
AppType = 2,
|
||||
};
|
||||
|
||||
static Win32Program azure_command_prompt = new Win32Program
|
||||
@@ -41,7 +41,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
||||
ExecutableName = "cmd.exe",
|
||||
FullPath = "c:\\windows\\system32\\cmd.exe",
|
||||
LnkResolvedPath = "c:\\programdata\\microsoft\\windows\\start menu\\programs\\microsoft azure\\microsoft azure sdk for .net\\v2.9\\microsoft azure command prompt - v2.9.lnk",
|
||||
AppType = 2
|
||||
AppType = 2,
|
||||
};
|
||||
|
||||
static Win32Program visual_studio_command_prompt = new Win32Program
|
||||
@@ -50,7 +50,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
||||
ExecutableName = "cmd.exe",
|
||||
FullPath = "c:\\windows\\system32\\cmd.exe",
|
||||
LnkResolvedPath = "c:\\programdata\\microsoft\\windows\\start menu\\programs\\visual studio 2019\\visual studio tools\\vc\\x64 native tools command prompt for vs 2019.lnk",
|
||||
AppType = 2
|
||||
AppType = 2,
|
||||
};
|
||||
|
||||
static Win32Program command_prompt = new Win32Program
|
||||
@@ -59,7 +59,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
||||
ExecutableName = "cmd.exe",
|
||||
FullPath = "c:\\windows\\system32\\cmd.exe",
|
||||
LnkResolvedPath = "c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\system tools\\command prompt.lnk",
|
||||
AppType = 2
|
||||
AppType = 2,
|
||||
};
|
||||
|
||||
static Win32Program file_explorer = new Win32Program
|
||||
@@ -68,7 +68,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
||||
ExecutableName = "File Explorer.lnk",
|
||||
FullPath = "c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\system tools\\file explorer.lnk",
|
||||
LnkResolvedPath = null,
|
||||
AppType = 2
|
||||
AppType = 2,
|
||||
};
|
||||
|
||||
static Win32Program wordpad = new Win32Program
|
||||
@@ -77,7 +77,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
||||
ExecutableName = "wordpad.exe",
|
||||
FullPath = "c:\\program files\\windows nt\\accessories\\wordpad.exe",
|
||||
LnkResolvedPath = "c:\\programdata\\microsoft\\windows\\start menu\\programs\\accessories\\wordpad.lnk",
|
||||
AppType = 2
|
||||
AppType = 2,
|
||||
};
|
||||
|
||||
static Win32Program wordpad_duplicate = new Win32Program
|
||||
@@ -86,7 +86,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
||||
ExecutableName = "WORDPAD.EXE",
|
||||
FullPath = "c:\\program files\\windows nt\\accessories\\wordpad.exe",
|
||||
LnkResolvedPath = null,
|
||||
AppType = 2
|
||||
AppType = 2,
|
||||
};
|
||||
|
||||
static Win32Program twitter_pwa = new Win32Program
|
||||
@@ -95,7 +95,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
||||
FullPath = "c:\\program files (x86)\\google\\chrome\\application\\chrome_proxy.exe",
|
||||
LnkResolvedPath = "c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\chrome apps\\twitter.lnk",
|
||||
Arguments = " --profile-directory=Default --app-id=jgeosdfsdsgmkedfgdfgdfgbkmhcgcflmi",
|
||||
AppType = 0
|
||||
AppType = 0,
|
||||
};
|
||||
|
||||
static Win32Program pinned_webpage = new Win32Program
|
||||
@@ -104,7 +104,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
||||
FullPath = "c:\\program files (x86)\\microsoft\\edge\\application\\msedge_proxy.exe",
|
||||
LnkResolvedPath = "c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\web page.lnk",
|
||||
Arguments = "--profile-directory=Default --app-id=homljgmgpmcbpjbnjpfijnhipfkiclkd",
|
||||
AppType = 0
|
||||
AppType = 0,
|
||||
};
|
||||
|
||||
static Win32Program edge_named_pinned_webpage = new Win32Program
|
||||
@@ -113,7 +113,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
||||
FullPath = "c:\\program files (x86)\\microsoft\\edge\\application\\msedge_proxy.exe",
|
||||
LnkResolvedPath = "c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\edge - bing.lnk",
|
||||
Arguments = " --profile-directory=Default --app-id=aocfnapldcnfbofgmbbllojgocaelgdd",
|
||||
AppType = 0
|
||||
AppType = 0,
|
||||
};
|
||||
|
||||
static Win32Program msedge = new Win32Program
|
||||
@@ -122,7 +122,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
||||
ExecutableName = "msedge.exe",
|
||||
FullPath = "c:\\program files (x86)\\microsoft\\edge\\application\\msedge.exe",
|
||||
LnkResolvedPath = "c:\\programdata\\microsoft\\windows\\start menu\\programs\\microsoft edge.lnk",
|
||||
AppType = 2
|
||||
AppType = 2,
|
||||
};
|
||||
|
||||
static Win32Program chrome = new Win32Program
|
||||
@@ -131,7 +131,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
||||
ExecutableName = "chrome.exe",
|
||||
FullPath = "c:\\program files (x86)\\google\\chrome\\application\\chrome.exe",
|
||||
LnkResolvedPath = "c:\\programdata\\microsoft\\windows\\start menu\\programs\\google chrome.lnk",
|
||||
AppType = 2
|
||||
AppType = 2,
|
||||
};
|
||||
|
||||
static Win32Program dummy_proxy_app = new Win32Program
|
||||
@@ -140,7 +140,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
||||
ExecutableName = "test_proxy.exe",
|
||||
FullPath = "c:\\program files (x86)\\microsoft\\edge\\application\\test_proxy.exe",
|
||||
LnkResolvedPath = "c:\\programdata\\microsoft\\windows\\start menu\\programs\\test proxy.lnk",
|
||||
AppType = 2
|
||||
AppType = 2,
|
||||
};
|
||||
|
||||
static Win32Program cmd_run_command = new Win32Program
|
||||
@@ -149,7 +149,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
||||
ExecutableName = "cmd.exe",
|
||||
FullPath = "c:\\windows\\system32\\cmd.exe",
|
||||
LnkResolvedPath = null,
|
||||
AppType = 3 // Run command
|
||||
AppType = 3, // Run command
|
||||
};
|
||||
|
||||
static Win32Program cmder_run_command = new Win32Program
|
||||
@@ -159,7 +159,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
||||
ExecutableName = "Cmder.exe",
|
||||
FullPath = "c:\\tools\\cmder\\cmder.exe",
|
||||
LnkResolvedPath = null,
|
||||
AppType = 3 // Run command
|
||||
AppType = 3, // Run command
|
||||
};
|
||||
|
||||
static Win32Program dummy_internetShortcut_app = new Win32Program
|
||||
@@ -169,7 +169,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
||||
FullPath = "steam://rungameid/1258080",
|
||||
ParentDirectory = "C:\\Users\\temp\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Steam",
|
||||
LnkResolvedPath = null,
|
||||
AppType = 1
|
||||
AppType = 1,
|
||||
};
|
||||
|
||||
static Win32Program dummy_internetShortcut_app_duplicate = new Win32Program
|
||||
@@ -179,7 +179,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
||||
FullPath = "steam://rungameid/1258080",
|
||||
ParentDirectory = "C:\\Users\\temp\\Desktop",
|
||||
LnkResolvedPath = null,
|
||||
AppType = 1
|
||||
AppType = 1,
|
||||
};
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
using Microsoft.Plugin.Program.Storage;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
// 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.Tasks;
|
||||
using Windows.Media.Capture;
|
||||
using NUnit.Framework;
|
||||
using Wox.Infrastructure.Storage;
|
||||
|
||||
namespace Microsoft.Plugin.Program.UnitTests.Storage
|
||||
@@ -18,51 +15,51 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
||||
[Test]
|
||||
public void ContainsShouldReturnTrueWhenListIsInitializedWithItem()
|
||||
{
|
||||
//Arrange
|
||||
// Arrange
|
||||
var itemName = "originalItem1";
|
||||
IRepository<string> repository = new ListRepository<string>() { itemName };
|
||||
|
||||
//Act
|
||||
// Act
|
||||
var result = repository.Contains(itemName);
|
||||
|
||||
//Assert
|
||||
// Assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ContainsShouldReturnTrueWhenListIsUpdatedWithAdd()
|
||||
{
|
||||
//Arrange
|
||||
// Arrange
|
||||
IRepository<string> repository = new ListRepository<string>();
|
||||
|
||||
//Act
|
||||
// Act
|
||||
var itemName = "newItem";
|
||||
repository.Add(itemName);
|
||||
var result = repository.Contains(itemName);
|
||||
|
||||
//Assert
|
||||
// Assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ContainsShouldReturnFalseWhenListIsUpdatedWithRemove()
|
||||
{
|
||||
//Arrange
|
||||
// Arrange
|
||||
var itemName = "originalItem1";
|
||||
IRepository<string> repository = new ListRepository<string>() { itemName };
|
||||
|
||||
//Act
|
||||
// Act
|
||||
repository.Remove(itemName);
|
||||
var result = repository.Contains(itemName);
|
||||
|
||||
//Assert
|
||||
// Assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AddShouldNotThrowWhenBeingIterated()
|
||||
{
|
||||
//Arrange
|
||||
// Arrange
|
||||
ListRepository<string> repository = new ListRepository<string>();
|
||||
var numItems = 1000;
|
||||
for (var i = 0; i < numItems; ++i)
|
||||
@@ -70,7 +67,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
||||
repository.Add($"OriginalItem_{i}");
|
||||
}
|
||||
|
||||
//Act - Begin iterating on one thread
|
||||
// Act - Begin iterating on one thread
|
||||
var iterationTask = Task.Run(() =>
|
||||
{
|
||||
var remainingIterations = 10000;
|
||||
@@ -78,7 +75,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
||||
{
|
||||
foreach (var item in repository)
|
||||
{
|
||||
//keep iterating
|
||||
// keep iterating
|
||||
|
||||
}
|
||||
--remainingIterations;
|
||||
@@ -86,7 +83,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
||||
|
||||
});
|
||||
|
||||
//Act - Insert on another thread
|
||||
// Act - Insert on another thread
|
||||
var addTask = Task.Run(() =>
|
||||
{
|
||||
for (var i = 0; i < numItems; ++i)
|
||||
@@ -95,14 +92,14 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
||||
}
|
||||
});
|
||||
|
||||
//Assert that this does not throw. Collections that aren't syncronized will throw an invalidoperatioexception if the list is modified while enumerating
|
||||
// Assert that this does not throw. Collections that aren't syncronized will throw an invalidoperatioexception if the list is modified while enumerating
|
||||
await Task.WhenAll(new Task[] { iterationTask, addTask }).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task RemoveShouldNotThrowWhenBeingIterated()
|
||||
{
|
||||
//Arrange
|
||||
// Arrange
|
||||
ListRepository<string> repository = new ListRepository<string>();
|
||||
var numItems = 1000;
|
||||
for (var i = 0; i < numItems; ++i)
|
||||
@@ -110,7 +107,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
||||
repository.Add($"OriginalItem_{i}");
|
||||
}
|
||||
|
||||
//Act - Begin iterating on one thread
|
||||
// Act - Begin iterating on one thread
|
||||
var iterationTask = Task.Run(() =>
|
||||
{
|
||||
var remainingIterations = 10000;
|
||||
@@ -118,7 +115,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
||||
{
|
||||
foreach (var item in repository)
|
||||
{
|
||||
//keep iterating
|
||||
// keep iterating
|
||||
|
||||
}
|
||||
--remainingIterations;
|
||||
@@ -126,7 +123,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
||||
|
||||
});
|
||||
|
||||
//Act - Remove on another thread
|
||||
// Act - Remove on another thread
|
||||
var addTask = Task.Run(() =>
|
||||
{
|
||||
for (var i = 0; i < numItems; ++i)
|
||||
@@ -135,7 +132,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
||||
}
|
||||
});
|
||||
|
||||
//Assert that this does not throw. Collections that aren't syncronized will throw an invalidoperatioexception if the list is modified while enumerating
|
||||
// Assert that this does not throw. Collections that aren't syncronized will throw an invalidoperatioexception if the list is modified while enumerating
|
||||
await Task.WhenAll(new Task[] { iterationTask, addTask }).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
// 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.
|
||||
|
||||
namespace Microsoft.Plugin.Program.UnitTests.Storage
|
||||
{
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
using System;
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Wox.Infrastructure.Storage;
|
||||
using Wox.Plugin;
|
||||
using Microsoft.Plugin.Program.Programs;
|
||||
using Microsoft.Plugin.Program.Storage;
|
||||
using System.IO;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Wox.Infrastructure.FileSystemHelper;
|
||||
using System.Diagnostics;
|
||||
using Wox.Infrastructure.Storage;
|
||||
|
||||
namespace Microsoft.Plugin.Program.UnitTests.Storage
|
||||
{
|
||||
@@ -47,7 +50,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
||||
Name = name,
|
||||
ExecutableName = exename,
|
||||
FullPath = fullPath,
|
||||
Description = description1
|
||||
Description = description1,
|
||||
};
|
||||
|
||||
Win32Program item2 = new Win32Program
|
||||
@@ -55,7 +58,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
||||
Name = name,
|
||||
ExecutableName = exename,
|
||||
FullPath = fullPath,
|
||||
Description = description2
|
||||
Description = description2,
|
||||
};
|
||||
|
||||
// Act
|
||||
@@ -357,7 +360,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
||||
ExecutableName = "path.exe",
|
||||
ParentDirectory = "directory",
|
||||
FullPath = "directory\\path.exe",
|
||||
LnkResolvedPath = "directory\\path.lnk" // This must be equal for lnk applications
|
||||
LnkResolvedPath = "directory\\path.lnk", // This must be equal for lnk applications
|
||||
};
|
||||
_win32ProgramRepository.Add(item);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user