Example #1
0
 /// <summary>
 /// Generiert die Werte der Verbindung 
 /// und somit den connectionString
 /// </summary>
 /// <param name="connection">Als Parameter wird ein Connection Objekt übergeben</param>
 public MSConnector(Connection connection)
 {
     this.connection = connection;
     ConnectionString = "Data Source=" + connection.Server + ";Initial Catalog="
         + connection.Database + ";User ID=" + connection.Username
         + ";Password=" + connection.Password;
 }
Example #2
0
 /// <summary>
 /// Generiert die Werte der Verbindung 
 /// und somit den connectionString
 /// </summary>
 /// <param name="connection">Beinhaltet alle benötigten Werte für den Verbindungsaufbau</param>
 public MyConnector(Connection connection)
 {
     this.connection = connection;
     ConnectionString = "SERVER=" + connection.Server + ";" +
                     "DATABASE=" + connection.Database + ";" +
                     "UID=" + connection.Username + ";" +
                     "PASSWORD="******";";
 }
 public void TypeTest()
 {
     Connection target = new Connection(); // TODO: Initialize to an appropriate value
     string expected = "int"; // TODO: Initialize to an appropriate value
     string actual;
     target.Type = expected;
     actual = target.Type;
     Assert.AreEqual(expected, actual);
 }
 public void ServerTest()
 {
     Connection target = new Connection(); // TODO: Initialize to an appropriate value
     string expected = "TestServer"; // TODO: Initialize to an appropriate value
     string actual;
     target.Server = expected;
     actual = target.Server;
     Assert.AreEqual(expected, actual);
 }
 public void PasswordTest()
 {
     Connection target = new Connection(); // TODO: Initialize to an appropriate value
     string expected = "1234"; // TODO: Initialize to an appropriate value
     string actual;
     target.Password = expected;
     actual = target.Password;
     Assert.AreEqual(expected, actual);
 }
 public void DatabaseTest()
 {
     Connection target = new Connection(); // TODO: Initialize to an appropriate value
     string expected = "TestDatenbank"; // TODO: Initialize to an appropriate value
     string actual;
     target.Database = expected;
     actual = target.Database;
     Assert.AreEqual(expected, actual);
 }
 /// <summary>
 /// Setzen der Parameter für eine ungültige Datenbankverbindung (unbekannter Benutzername)
 /// </summary>
 public void InitializeFailedUserName()
 {
     Connection connection = new Connection();
     connection.Server = "localhost";
     connection.Database = "school_example";
     connection.Username = "******";
     connection.Password = "******";
     connector = new MyConnector(connection);
 }
 /// <summary>
 /// Setzen der Parameter für eine ungültige Datenbankverbindung (unbekannte Datenbank)
 /// </summary>
 public void InitializeFailedDatabase()
 {
     Connection connection = new Connection();
     connection.Server = "localhost";
     connection.Database = "..";
     connection.Username = "******";
     connection.Password = "******";
     connector = new MyConnector(connection);
 }
 /// <summary>
 /// Setzen der Parameter für eine ungültige Datenbankverbindung (unbekannter Server)
 /// </summary>
 public void InitializeFailedConnection()
 {
     Connection connection = new Connection();
     connection.Server = "1.1.1.1";
     connection.Database = "school_example";
     connection.Username = "******";
     connection.Password = "******";
     connector = new MyConnector(connection);
 }
Example #10
0
 /// <summary>
 /// Fügt eine Verbindung mit all den Parameter züruck
 /// </summary>
 /// <param name="connection"></param>
 public void AddConnection(Connection connection)
 {
     connections.Add(connection);
 }
Example #11
0
 /// <summary>
 /// Der Knoten Connections wird verarbeitet
 /// Sobald der XmlReader einen Knoten namens Connection findet instanziiert er ein neues Connection Objekt
 /// ,die gewünschten Eigenschaften übergeben und das gesamte Objekt der Liste Connections hinzugefügt.
 /// 
 /// </summary>
 /// <param name="xml">Als Parameter wird der Knoten Connections und all seine Unterknoten übergeben</param>
 public void Connection(string xml)
 {
     XmlReader reader = XmlReader.Create(new System.IO.StringReader(xml));
     Connection connection = null;
     while (reader.Read())
     {
         if (reader.NodeType == XmlNodeType.Element)
         {
             switch (reader.Name)
             {
                 case "connection":
                     connection = new Connection();
                     AddConnection(connection);
                     break;
                 case "id":
                     connection.Id = reader.ReadElementString();
                     break;
                 case "type":
                     connection.Type = reader.ReadElementString();
                     break;
                 case "server":
                     connection.Server = reader.ReadElementString();
                     break;
                 case "database":
                     connection.Database = reader.ReadElementString();
                     break;
                 case "user":
                     connection.Username = reader.ReadElementString();
                     break;
                 case "password":
                     connection.Password = reader.ReadElementString();
                     break;
             }
         }
     }
     reader.Close();
 }
Example #12
0
 /// <summary>
 /// Setzt Werte für die Datenbankverbindung ein
 /// </summary>
 public void InitializeDBConnection()
 {
     connections.Clear();
     Connection connection = new Connection();
     connection.Id = "mysql";
     connection.Type = "MySQL";
     connection.Server = "localhost";
     connection.Database = "school_example";
     connection.Username = "******";
     connection.Password = "******";
     connections.Add(connection);
 }
 /// <summary>
 /// Setzen der Parameter für eine gültige Datenbankverbindung
 /// </summary>
 public void InitalizeConnection()
 {
     Connection connection = new Connection();
     connection.Server = "localhost\\SQLExpress";
     connection.Database = "school_example";
     connection.Username = "******";
     connection.Password = "******";
     connector = new MSConnector(connection);
 }
Example #14
0
 public void UsernameTest()
 {
     Connection target = new Connection(); // TODO: Initialize to an appropriate value
     string expected = "Benuter"; // TODO: Initialize to an appropriate value
     string actual;
     target.Username = expected;
     actual = target.Username;
     Assert.AreEqual(expected, actual);
 }