Example #1
0
TEST(D_FileSystemTest, Folders_Create_3)
{
	ASSERT_TRUE(DatabasePrepare());

	FoldersNames_vt foldsNames;
	const unsigned char foldsInPack = 5;
	CreateFoldNames(foldsInPack, foldsNames);
	ASSERT_FALSE(foldsNames.empty());
	FolderGuard root;
	ASSERT_NO_THROW(root = cont->GetRoot());

	for (int i = 1; i < foldsInPack; ++i)
	{
		FolderGuard new_root;
		ASSERT_NO_THROW(new_root = root->CreateFolder(foldsNames[i]));

		for (int j = 0; j < foldsInPack; ++j)
		{
			ElementGuard ce;
			EXPECT_NO_THROW(new_root->CreateChild(foldsNames[j], ElementTypeFolder));
			EXPECT_NO_THROW(ce = new_root->GetChild(foldsNames[j]));
			EXPECT_EQ(foldsNames[j], ce->Name());
			EXPECT_EQ(ElementTypeFolder, ce->Type());
			Folder* cf = ce->AsFolder();
			ASSERT_NE(cf, nullptr);

			EXPECT_THROW(new_root->CreateChild(foldsNames[j], ElementTypeFolder), ContainerException);
			EXPECT_THROW(new_root->CreateChild(foldsNames[j], ElementTypeFile), ContainerException);
			std::string compared_path(utils::SlashedPath(new_root->Path()) + foldsNames[j]);
			EXPECT_EQ(compared_path, cf->Path());
		}
	}
}