Exemplo n.º 1
0
MSXML2::IXMLDOMNodePtr AccessDatabase::Save(AppSecInc::Xml::XmlDocument& xmldoc, MSXML2::IXMLDOMNodePtr parent) const
{
    MSXML2::IXMLDOMNodePtr root = xmldoc.AppendChild(L"AccessDatabase", parent);
    xmldoc.AppendChild(L"DBQ", root)->text = _bstr_t(_dbq.c_str());
    xmldoc.AppendChild(L"ConnectionString", root)->text = _bstr_t(AppSecInc::Crypt::DPAPIImpl::Protect(_connection_string).c_str());
    return root;
}
Exemplo n.º 2
0
void XmlDocumentUnitTests::testSetAttribute()
{
	AppSecInc::Xml::XmlDocument xml;
    xml.Create();
    xml.AppendChild(L"xml");

    {
        xml.SetAttribute(L"name", L"value", xml.SelectNode(L"/xml"));
        std::wstring data = xml.GetXml();
        AppSecInc::StringUtils::lrtrim(data, L"\r\n");
        std::wcout << std::endl << data;
        CPPUNIT_ASSERT(data == L"<xml name=\"value\"/>");
    }
}
Exemplo n.º 3
0
void XmlDocumentUnitTests::testAppendChild()
{
	AppSecInc::Xml::XmlDocument xml;
    xml.Create();
    xml.AppendChild(L"xml");

    {
        std::wstring data = xml.GetXml();
        AppSecInc::StringUtils::lrtrim(data, L"\r\n");
        std::wcout << std::endl << data;
        CPPUNIT_ASSERT(! data.empty());
        CPPUNIT_ASSERT(data == L"<xml/>");
    }

    {
        xml.AppendChild(L"node", xml.SelectNode(L"/xml"));
        std::wstring data = xml.GetXml();
        AppSecInc::StringUtils::lrtrim(data, L"\r\n");
        std::wcout << std::endl << data;
        CPPUNIT_ASSERT(! data.empty());
        CPPUNIT_ASSERT(data == L"<xml><node/></xml>");
    }
}
Exemplo n.º 4
0
void AccessDatabaseUnitTests::testLoadSave()
{
    AccessDatabase database1;
    database1.SetDBQ(L"test");

    AppSecInc::Xml::XmlDocument doc;
    doc.Create();
    MSXML2::IXMLDOMNodePtr root = doc.AppendChild(L"Databases");
    MSXML2::IXMLDOMNodePtr database_root = database1.Save(doc, root);

    std::wcout << std::endl << doc.GetXml();

    AccessDatabase database2;
    database2.Load(doc, database_root);

    CPPUNIT_ASSERT(database2.GetDBQ() == database1.GetDBQ());
}