private void AccessDeserializedObjectTest() { // Create a new Connection-Object IConnection myConnection = new Connection() { Name = "TestConnection", ConnectionType = CockpitConfigType.OPC, Password = "******", Username = "******", Uri = "http://www.yahoo.de" }; // Add it toBeTested.Add(myConnection); Assert.AreEqual(toBeTested.Connections.Length, 3, "Not the right number of connections"); // Check for an existing Object and parameters Connection conn; toBeTested.GetConnection("Oracle Singapore", out conn); Assert.IsInstanceOfType(conn, typeof(Connection)); Assert.AreEqual(conn.Username, "EgonMaierDietrich"); // Check correct removal of Connections toBeTested.Remove(myConnection); Assert.AreEqual(toBeTested.Connections.Length, 2, "Not the right number of connections"); }
/// <summary> /// returns a connection with the given name in connection param /// </summary> /// <param name="name"></param> /// <param name="connection"></param> /// <returns></returns> public bool GetConnection(string name, out Connection connection) { Connection result; if (!dicConns.TryGetValue(name, out result)) { connection = null; return false; } connection = result; return true; }