49 lines
1.6 KiB
C++
49 lines
1.6 KiB
C++
#include "stdafx.h"
|
|
#include "CppUnitTest.h"
|
|
#include <SiaApi.h>
|
|
#include "UnitTestConfig.h"
|
|
|
|
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
|
|
|
namespace UnitTests
|
|
{
|
|
TEST_CLASS(SiaApiFileTree)
|
|
{
|
|
DAEMON_TEST()
|
|
|
|
private:
|
|
const SiaHostConfig _hostConfig = { TEST_SERVER_AND_PORT, TEST_SERVER_VERSION };
|
|
|
|
public:
|
|
TEST_METHOD(BuildFileTree)
|
|
{
|
|
CSiaCurl siaCurl;
|
|
siaCurl.SetHostConfig(_hostConfig);
|
|
|
|
json j =
|
|
{
|
|
{"files",
|
|
{
|
|
{ { "siapath", "root/sub1/file1.txt" },{ "filesize", 1 },{ "available", true },{ "renewing", true },{ "redundancy", 5 },{ "uploadprogress", 100 },{ "expiration", 60000 } },
|
|
{ { "siapath", "root/sub1/file2.txt" },{ "filesize", 2 },{ "available", true },{ "renewing", true },{ "redundancy", 5 },{ "uploadprogress", 100 },{ "expiration", 60000 } },
|
|
{ { "siapath", "root/sub1/file3.txt" },{ "filesize", 3 },{ "available", true },{ "renewing", true },{ "redundancy", 5 },{ "uploadprogress", 100 },{ "expiration", 60000 } }
|
|
}}
|
|
};
|
|
|
|
CSiaFileTree ft(siaCurl);
|
|
ft.BuildTree(j);
|
|
auto fileList = ft.GetFileList();
|
|
Assert::AreEqual(static_cast<size_t>(3), fileList.size());
|
|
|
|
Assert::AreEqual(L"root/sub1/file1.txt", fileList[0]->GetSiaPath().c_str());
|
|
Assert::AreEqual(L"root/sub1/file2.txt", fileList[1]->GetSiaPath().c_str());
|
|
Assert::AreEqual(L"root/sub1/file3.txt", fileList[2]->GetSiaPath().c_str());
|
|
|
|
Assert::AreEqual(static_cast<std::uint64_t>(1), fileList[0]->GetFileSize());
|
|
Assert::AreEqual(static_cast<std::uint64_t>(2), fileList[1]->GetFileSize());
|
|
Assert::AreEqual(static_cast<std::uint64_t>(3), fileList[2]->GetFileSize());
|
|
}
|
|
};
|
|
|
|
DEFINE_DAEMON(SiaApiFileTree);
|
|
} |