1
0
This repository has been archived on 2025-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
Files
siadrive/UnitTests/SiaApiTests.cpp
Scott E. Graves 3c1dd68622 Dokan changes
2017-02-11 19:42:51 -06:00

66 lines
1.5 KiB
C++

#include "stdafx.h"
#include "CppUnitTest.h"
#include <SiaApi.h>
#include "UnitTestConfig.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)
{
CSiaApi api(_hostConfig);
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);
}