#include "stdafx.h" #include "CppUnitTest.h" #include #include "UnitTestConfig.h" #include "SiaDriveConfig.h" using namespace Microsoft::VisualStudio::CppUnitTestFramework; using namespace Sia::Api; namespace UnitTests { TEST_CLASS(SiaApi) { DAEMON_TEST() private: const SiaHostConfig _hostConfig = { TEST_SERVER_AND_PORT, TEST_SERVER_VERSION }; public: TEST_METHOD(GetServerVersion) { CSiaDriveConfig driveConfig; CSiaApi api(_hostConfig, &driveConfig); Assert::IsTrue(api.GetServerVersion() == TEST_SERVER_VERSION); } TEST_METHOD(RelativePathToSiaPath) { String relPath = L"test\\moose\\cow.txt"; String siaPath = CSiaApi::FormatToSiaPath(relPath); Assert::AreEqual(L"test/moose/cow.txt", siaPath.c_str()); } TEST_METHOD(RelativePathWithBeginningBackslashToSiaPath) { String relPath = L"\\test\\moose\\cow.txt"; String siaPath = CSiaApi::FormatToSiaPath(relPath); Assert::AreEqual(L"test/moose/cow.txt", siaPath.c_str()); } TEST_METHOD(RelativePathWithBeginningBackslashOnlyToSiaPath) { String relPath = L"\\"; String siaPath = CSiaApi::FormatToSiaPath(relPath); Assert::AreEqual(L"", siaPath.c_str()); } TEST_METHOD(FilenameOnlyToSiaPath) { String relPath = L"moose.txt"; String siaPath = CSiaApi::FormatToSiaPath(relPath); Assert::AreEqual(L"moose.txt", siaPath.c_str()); } TEST_METHOD(RemoveExtraBackslashes) { String relPath = L"\\\\\\\\test\\\\\\\\\\\\\\\\\\moose\\\\\\\\\\\\cow.txt"; String siaPath = CSiaApi::FormatToSiaPath(relPath); Assert::AreEqual(L"test/moose/cow.txt", siaPath.c_str()); } }; DEFINE_DAEMON(SiaApi); }