68 lines
1.6 KiB
C++
68 lines
1.6 KiB
C++
#include "stdafx.h"
|
|
#include "CppUnitTest.h"
|
|
#include <SiaApi.h>
|
|
#include "UnitTestConfig.h"
|
|
#include "SiaDriveConfig.h"
|
|
|
|
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
|
|
|
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);
|
|
} |