Пример #1
0
TEST(RepoBSONFactoryTest, MakeMetaDataNodeTest)
{
	RepoBSON data = BSON("something" << "Something else" << "something2" << "somethingelse2");
	std::string mimeType = "application/x-mswrite";
	std::string name = "MetaTest";

	MetadataNode metaNode = RepoBSONFactory::makeMetaDataNode(data, mimeType, name);

	EXPECT_FALSE(metaNode.isEmpty());
	EXPECT_EQ(name, metaNode.getName());
	EXPECT_EQ(metaNode.getTypeAsEnum(), NodeType::METADATA);

	EXPECT_EQ(mimeType, metaNode.getStringField(REPO_LABEL_MEDIA_TYPE));

	EXPECT_EQ(data.toString(), metaNode.getObjectField(REPO_NODE_LABEL_METADATA).toString());
}
Пример #2
0
TEST(RepoBSONFactoryTest, MakeMetaDataNodeTest2)
{
	std::vector<std::string> keys({ "one", "two", "three", "four", "five" }), values({ "!", "!!", "!!!", "!!!!", "!!!!!" });

	std::string name = "MetaTest";

	MetadataNode metaNode = RepoBSONFactory::makeMetaDataNode(keys, values, name);

	EXPECT_FALSE(metaNode.isEmpty());
	EXPECT_EQ(name, metaNode.getName());
	EXPECT_EQ(metaNode.getTypeAsEnum(), NodeType::METADATA);

	auto metaBSON = metaNode.getObjectField(REPO_NODE_LABEL_METADATA);

	ASSERT_FALSE(metaBSON.isEmpty());

	for (uint32_t i = 0; i < keys.size(); ++i)
	{
		ASSERT_TRUE(metaBSON.hasField(keys[i]));
		EXPECT_EQ(values[i], metaBSON.getStringField(keys[i]));
	}
}