public void TestAddAndDeleteAgent() { List <AgentDataModel> agentsBeforeAdd = databaseConnection.GetAgentsFromDatabase(); AgentDataModel newAgent = new AgentDataModel(1, "Test-Server", "10.10.10.10", 1, 161, 1, "", "", ""); databaseConnection.AddAgentToDatabase(newAgent, false, false); List <AgentDataModel> agentsAfterAdd = databaseConnection.GetAgentsFromDatabase(); Assert.AreEqual(agentsBeforeAdd.Count + 1, agentsAfterAdd.Count); // Check old Agents int i; for (i = 0; i < agentsBeforeAdd.Count; i++) { Assert.AreEqual(agentsBeforeAdd[i].AgentNr, agentsAfterAdd[i].AgentNr); Assert.AreEqual(agentsBeforeAdd[i].Name, agentsAfterAdd[i].Name); Assert.AreEqual(agentsBeforeAdd[i].IPAddress, agentsAfterAdd[i].IPAddress); Assert.AreEqual(agentsBeforeAdd[i].TypeNr, agentsAfterAdd[i].TypeNr); Assert.AreEqual(agentsBeforeAdd[i].Port, agentsAfterAdd[i].Port); Assert.AreEqual(agentsBeforeAdd[i].Status, agentsAfterAdd[i].Status); Assert.AreEqual(agentsBeforeAdd[i].SysDescription, agentsAfterAdd[i].SysDescription); Assert.AreEqual(agentsBeforeAdd[i].SysName, agentsAfterAdd[i].SysName); Assert.AreEqual(agentsBeforeAdd[i].SysUptime, agentsAfterAdd[i].SysUptime); } // Check new Agent Assert.AreEqual(newAgent.Name, agentsAfterAdd[i].Name); Assert.AreEqual(newAgent.IPAddress, agentsAfterAdd[i].IPAddress); Assert.AreEqual(newAgent.TypeNr, agentsAfterAdd[i].TypeNr); Assert.AreEqual(newAgent.Port, agentsAfterAdd[i].Port); Assert.AreEqual(newAgent.Status, agentsAfterAdd[i].Status); // Delete new Agent databaseConnection.DeleteAgentInDatabase(agentsAfterAdd[i].AgentNr); List <AgentDataModel> agentsAfterDelete = databaseConnection.GetAgentsFromDatabase(); Assert.AreEqual(agentsAfterDelete.Count, agentsBeforeAdd.Count); }