1
0

More changes

This commit is contained in:
Scott E. Graves
2017-02-04 00:51:43 -06:00
parent 232e71e57c
commit 43b301f0bc
15 changed files with 200 additions and 43 deletions

View File

@@ -22,5 +22,5 @@ namespace UnitTests
}
};
Daemon SiaApi::_daemon;
DEFINE_DAEMON(SiaApi);
}

View File

@@ -73,5 +73,5 @@ namespace UnitTests
}
};
Daemon SiaCurl::_daemon;
DEFINE_DAEMON(SiaCurl);
}

View File

@@ -0,0 +1,20 @@
#include "stdafx.h"
#include "CppUnitTest.h"
#include "SiaDriveConfig.h"
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTests
{
TEST_CLASS(SiaDriveConfig)
{
public:
TEST_METHOD(DefaultFileCreation)
{
Sia::Api::CSiaDriveConfig cfg(L".\\test_cfg.json");
Assert::AreEqual(static_cast<uint8_t>(0), cfg.GetUI_Main_TabIndex());
Assert::IsTrue(PathFileExists(L".\\test_cfg.json"));
Assert::AreEqual(L".\\test_cfg.json", cfg.GetFilePath().c_str());
}
};
}

View File

@@ -43,5 +43,5 @@ namespace UnitTests
}
};
Daemon SiaWalletApi::_daemon;
DEFINE_DAEMON(SiaWalletApi);
}

View File

@@ -1,15 +1,24 @@
#pragma once
#define TEST_SERVER_AND_PORT L"localhost", 19980
#define TEST_SERVER_HOST L"localhost"
#define TEST_SERVER_PORT 11980
#define TEST_SERVER_AND_PORT TEST_SERVER_HOST, TEST_SERVER_PORT
#define TEST_SERVER_VERSION L"1.1.0"
using namespace Sia::Api;
class Daemon
{
public:
~Daemon()
{
Stop();
}
private:
PROCESS_INFORMATION pi;
STARTUPINFO si;
private:
void Cleanup()
{
@@ -26,17 +35,18 @@ private:
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
}
public:
void Start()
{
Cleanup();
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
String szCmdline = L"\"..\\..\\3rd-party\\Sia-v1.1.0-windows-amd64\\siad.exe\" -d .\\data --api-addr localhost:19980";
String szCmdline = L"\"..\\..\\3rd-party\\Sia-v1.1.0-windows-amd64\\siad.exe\" -d .\\data --api-addr " + String(TEST_SERVER_HOST) + L":" + std::to_wstring(TEST_SERVER_PORT) + L" --no-bootstrap";
CreateProcess(nullptr, &szCmdline[0], nullptr, nullptr, TRUE, 0, nullptr, nullptr, &si, &pi);
}
@@ -67,4 +77,7 @@ public:
TEST_CLASS_CLEANUP(StopDaemon)\
{\
_daemon.Stop();\
}
}
#define DEFINE_DAEMON(class) Daemon class::_daemon

View File

@@ -163,6 +163,10 @@
<SubType>
</SubType>
</ClCompile>
<ClCompile Include="SiaDriveConfigTests.cpp">
<SubType>
</SubType>
</ClCompile>
<ClCompile Include="SiaWalletApiTests.cpp">
<SubType>
</SubType>

View File

@@ -38,5 +38,8 @@
<ClCompile Include="SiaWalletApiTests.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SiaDriveConfigTests.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>