Some refactoring of FancyZones::IsInterestingWindow and added Unit Tests (#1521)

* Some refactoring of FancyZones::IsInterestingWindow and added UnitTests
This commit is contained in:
Yevhenii Holovachov
2020-03-16 14:25:30 +02:00
committed by GitHub
parent 04027b9c32
commit 02857d1b7f
6 changed files with 85 additions and 6 deletions

View File

@@ -91,10 +91,11 @@
<Link>
<SubSystem>Windows</SubSystem>
<AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>RuntimeObject.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>RuntimeObject.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="UnitTestsCommon.cpp" />
<ClCompile Include="UnitTestsVersionHelper.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>

View File

@@ -24,6 +24,9 @@
<ClCompile Include="UnitTestsVersionHelper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="UnitTestsCommon.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h">

View File

@@ -0,0 +1,57 @@
#include "pch.h"
#include "common.h"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTestsCommon
{
TEST_CLASS (CommonUtils)
{
std::vector<std::wstring> what_global{
L"TELEGRAM",
L"SUBLIME TEXT",
L"PROGRAM",
L"TEXT",
};
TEST_METHOD (FindAppNameInPathTest1)
{
std::wstring where(L"C:\\USERS\\GUEST\\APPDATA\\ROAMING\\TELEGRAM DESKTOP\\TELEGRAM.EXE");
bool ans = find_app_name_in_path(where, what_global);
Assert::IsTrue(ans);
}
TEST_METHOD (FindAppNameInPathTest2)
{
std::vector<std::wstring> what{
L"NOTEPAD",
};
std::wstring where(L"C:\\PROGRAM FILES\\NOTEPAD++\\NOTEPAD++.EXE");
bool ans = find_app_name_in_path(where, what);
Assert::IsTrue(ans);
}
TEST_METHOD (FindAppNameInPathTest3)
{
std::vector<std::wstring> what{
L"NOTEPAD++.EXE",
};
std::wstring where(L"C:\\PROGRAM FILES\\NOTEPAD++\\NOTEPAD++.EXE");
bool ans = find_app_name_in_path(where, what);
Assert::IsTrue(ans);
}
TEST_METHOD (FindAppNameInPathTest4)
{
std::wstring where(L"C:\\PROGRAM FILES\\SUBLIME TEXT 3\\SUBLIME_TEXT.EXE");
bool ans = find_app_name_in_path(where, what_global);
Assert::IsFalse(ans);
}
TEST_METHOD (FindAppNameInPathTest5)
{
std::vector<std::wstring> what{
L"NOTEPAD.EXE",
};
std::wstring where(L"C:\\PROGRAM FILES\\NOTEPAD++\\NOTEPAD++.EXE");
bool ans = find_app_name_in_path(where, what);
Assert::IsFalse(ans);
}
};
}