Enabling warnings as errors and correcting StyleCop issues (#6007)

This commit is contained in:
Clint Rutkas 2020-08-17 13:11:59 -07:00 committed by GitHub
parent 315caaba1c
commit 9d46fae865
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 19 deletions

View File

@ -49,7 +49,7 @@ namespace Wox.Test.Plugins
string pattern = "*";
WindowsSearchAPI api = GetWindowsSearchAPI();
WindowsSearchAPI.InitQueryHelper(out queryHelper, 10, api.DisplayHiddenFiles);
// Act
WindowsSearchAPI.ModifyQueryHelper(ref queryHelper, pattern);
@ -201,12 +201,12 @@ namespace Wox.Test.Plugins
public void WindowsSearchAPI_ShouldRequestNormalRequest_WhenDisplayHiddenFilesIsTrue()
{
ISearchQueryHelper queryHelper;
String pattern = "notepad";
WindowsSearchAPI _api = GetWindowsSearchAPI();
_api.DisplayHiddenFiles = true;
string pattern = "notepad";
WindowsSearchAPI api = GetWindowsSearchAPI();
api.DisplayHiddenFiles = true;
// Act
WindowsSearchAPI.InitQueryHelper(out queryHelper, 10, _api.DisplayHiddenFiles);
WindowsSearchAPI.InitQueryHelper(out queryHelper, 10, api.DisplayHiddenFiles);
WindowsSearchAPI.ModifyQueryHelper(ref queryHelper, pattern);
// Assert
@ -217,32 +217,31 @@ namespace Wox.Test.Plugins
public void WindowsSearchAPI_ShouldRequestFilteredRequest_WhenDisplayHiddenFilesIsFalse()
{
ISearchQueryHelper queryHelper;
String pattern = "notepad";
WindowsSearchAPI _api = GetWindowsSearchAPI();
_api.DisplayHiddenFiles = false;
string pattern = "notepad";
WindowsSearchAPI api = GetWindowsSearchAPI();
api.DisplayHiddenFiles = false;
// Act
WindowsSearchAPI.InitQueryHelper(out queryHelper, 10, _api.DisplayHiddenFiles);
WindowsSearchAPI.InitQueryHelper(out queryHelper, 10, api.DisplayHiddenFiles);
WindowsSearchAPI.ModifyQueryHelper(ref queryHelper, pattern);
// Assert
Assert.IsTrue(queryHelper.QueryWhereRestrictions.Contains("AND System.FileAttributes <> SOME BITWISE 2"));
}
[Test]
public void WindowsSearchAPI_ShouldRequestNormalRequest_WhenDisplayHiddenFilesIsTrue_AfterRuntimeSwap()
{
ISearchQueryHelper queryHelper;
String pattern = "notepad";
WindowsSearchAPI _api = GetWindowsSearchAPI();
_api.DisplayHiddenFiles = false;
string pattern = "notepad";
WindowsSearchAPI api = GetWindowsSearchAPI();
api.DisplayHiddenFiles = false;
// Act
WindowsSearchAPI.InitQueryHelper(out queryHelper, 10, _api.DisplayHiddenFiles);
WindowsSearchAPI.InitQueryHelper(out queryHelper, 10, api.DisplayHiddenFiles);
WindowsSearchAPI.ModifyQueryHelper(ref queryHelper, pattern);
_api.DisplayHiddenFiles = true;
WindowsSearchAPI.InitQueryHelper(out queryHelper, 10, _api.DisplayHiddenFiles);
api.DisplayHiddenFiles = true;
WindowsSearchAPI.InitQueryHelper(out queryHelper, 10, api.DisplayHiddenFiles);
WindowsSearchAPI.ModifyQueryHelper(ref queryHelper, pattern);
// Assert
@ -416,10 +415,10 @@ namespace Wox.Test.Plugins
List<OleDBResult> results = new List<OleDBResult>() { file1, file2 };
var mock = new Mock<ISearch>();
mock.Setup(x => x.Query(It.IsAny<string>(), It.IsAny<string>())).Returns(results);
WindowsSearchAPI _api = new WindowsSearchAPI(mock.Object, false);
WindowsSearchAPI api = new WindowsSearchAPI(mock.Object, false);
// Act
var windowsSearchAPIResults = _api.Search("file", true);
var windowsSearchAPIResults = api.Search("file", true);
// Assert
Assert.IsTrue(windowsSearchAPIResults.Count() == 0);

View File

@ -39,7 +39,13 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Plugins\Microsoft.Plugin.Folder\Microsoft.Plugin.Folder.csproj" />
<ProjectReference Include="..\Plugins\Microsoft.Plugin.Indexer\Microsoft.Plugin.Indexer.csproj" />