Implement the Client create interface

This commit also implement the D-Bus service which would be
used for snmp client configuration and would add the
snmp manager/trap receiver D-Bus objects under
namespace /xyz/openbmc_project/network/snmp/manager/

It implements the delete interface for SNMP client D-Bus Object.

Resolves openbmc/openbmc#3057

Change-Id: I0df7b1475f81325b9ac497c1fb350c3f62329686
Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
diff --git a/test/test_snmp_conf_manager.cpp b/test/test_snmp_conf_manager.cpp
new file mode 100644
index 0000000..ab29215
--- /dev/null
+++ b/test/test_snmp_conf_manager.cpp
@@ -0,0 +1,91 @@
+#include "snmp_conf_manager.hpp"
+
+#include "xyz/openbmc_project/Common/error.hpp"
+
+#include <gtest/gtest.h>
+#include <sdbusplus/bus.hpp>
+
+namespace phosphor
+{
+namespace network
+{
+namespace snmp
+{
+
+class TestSNMPConfManager : public testing::Test
+{
+  public:
+    sdbusplus::bus::bus bus;
+    ConfManager manager;
+    std::string confDir;
+    TestSNMPConfManager() :
+        bus(sdbusplus::bus::new_default()), manager(bus, ""){};
+
+    ~TestSNMPConfManager()
+    {
+    }
+
+    void createSNMPClient(std::string ipaddress, uint16_t port)
+    {
+        manager.client(ipaddress, port);
+    }
+
+    ClientList &getSNMPClients()
+    {
+        return manager.clients;
+    }
+
+    void deleteSNMPClient(std::string ipaddress)
+    {
+        if (manager.clients.find(ipaddress) != manager.clients.end())
+        {
+            auto &it = manager.clients[ipaddress];
+            it->delete_();
+        }
+    }
+};
+
+// Add single SNMP client
+TEST_F(TestSNMPConfManager, AddSNMPClient)
+{
+    using namespace sdbusplus::xyz::openbmc_project::Common::Error;
+
+    createSNMPClient("192.168.1.1", 24);
+
+    auto &clients = getSNMPClients();
+    EXPECT_EQ(1, clients.size());
+    EXPECT_EQ(true, clients.find("192.168.1.1") != clients.end());
+}
+
+// Add multiple SNMP client
+TEST_F(TestSNMPConfManager, AddMultipleSNMPClient)
+{
+    using namespace sdbusplus::xyz::openbmc_project::Common::Error;
+
+    createSNMPClient("192.168.1.1", 24);
+    createSNMPClient("192.168.1.2", 24);
+
+    auto &clients = getSNMPClients();
+    EXPECT_EQ(2, clients.size());
+    EXPECT_EQ(true, clients.find("192.168.1.1") != clients.end());
+    EXPECT_EQ(true, clients.find("192.168.1.2") != clients.end());
+}
+
+// Delete SNMP client
+TEST_F(TestSNMPConfManager, DeleteSNMPClient)
+{
+    using namespace sdbusplus::xyz::openbmc_project::Common::Error;
+
+    createSNMPClient("192.168.1.1", 24);
+    createSNMPClient("192.168.1.2", 24);
+
+    auto &clients = getSNMPClients();
+    EXPECT_EQ(2, clients.size());
+    deleteSNMPClient("192.168.1.1");
+    EXPECT_EQ(1, clients.size());
+    EXPECT_EQ(true, clients.find("192.168.1.2") != clients.end());
+}
+
+} // namespace snmp
+} // namespce network
+} // namespace phosphor