Add Tests

This commit is contained in:
2020-05-01 11:15:15 +02:00
parent a45717eaf6
commit 863f0db365
14 changed files with 351 additions and 2 deletions
+45
View File
@@ -0,0 +1,45 @@
#include "UseDatabase.h"
#include "MySQLClient.h"
#include <Logging.h>
#include <StringAlgorithm.h>
#include <sstream>
#include <unistd.h>
namespace Test {
bool UseDatabase()
{
Logging::Log(Logging::Severity::Info, "UseDatabase");
try
{
std::string hostname1 = "MySQL";
std::string username1 = "datalog";
std::string password1 = "NfhdUwjjdRbslR";
std::string database1 = "datalog";
MySQL::MySQLClient MySQLClient1;
MySQLClient1.Connect(hostname1, username1, password1, database1);
if (!MySQLClient1.Connected())
return false;
if (!StringAlgorithm::iequals(MySQLClient1.Database(), database1))
return false;
}
catch (const std::exception& e)
{
std::stringstream ss;
ss << "ERROR: " << e.what() << std::endl;
Logging::Log(Logging::Severity::Error, ss.str());
return false;
}
return true;
}
} // namespace Test