#include "pch.h" #include "CppUnitTest.h" #include "../NetTunnelSDK/tunnel.h" #include "../NetTunnelSDK/usrerr.h" #include "../NetTunnelSDK/misc.h" using namespace Microsoft::VisualStudio::CppUnitTestFramework; namespace TestNetTunnelSDK { TEST_MODULE_INITIALIZE(ModuleInitialize) { Logger::WriteMessage("In Module Initialize"); TunnelSDKInitEnv(TEXT( "C:\\Users\\HuangXin\\Documents\\development\\visual_studio\\tunnel_windows\\NetTunnelApp\\bin\\Debug")); InitTunnelSDKLog( TEXT( "C:\\Users\\HuangXin\\Documents\\development\\visual_studio\\tunnel_windows\\NetTunnelApp\\bin\\Debug\\utest.log"), LOG_DEBUG); } TEST_MODULE_CLEANUP(ModuleCleanup) { Logger::WriteMessage("In Module Cleanup"); TunnelSDKUnInit(); } TEST_CLASS(TestNetTunnelSDK) { public: TEST_METHOD(TestFindWireguardExe) { int ret = ERR_SUCCESS; Assert::AreEqual(ret, FindWireguardExe(nullptr, 0)); } TEST_METHOD(TestSetWireguardPath) { int ret = ERR_SUCCESS; Assert::AreEqual(ret, SetWireguardPath(TEXT("C:\\Program Files\\WireGuard\\wireguard.exe"))); } TEST_METHOD(TestRunPipeCmd) { #if 0 TCHAR buf[1024]; int ret = ERR_SUCCESS; Assert::AreEqual(ret, RunCommand(TEXT("cmd.exe /C dir E:\\"), buf, 1024)); Logger::WriteMessage("Return:"); Logger::WriteMessage(buf); #endif } TEST_METHOD(TestGetAllNICInfo) { PNIC_CONTENT pInfo = (PNIC_CONTENT)malloc(sizeof(NIC_CONTENT) * 32); int size = 0; int ret = ERR_SUCCESS; Assert::AreEqual(ret, GetAllNICInfo(pInfo, &size)); free(pInfo); } }; }