/// <summary>
        /// Verändert einen bestehenden Datensatz der Entität 'Arbeitsspeicher' in der Datenbank.
        /// </summary>
        /// <param name="entity">Die veränderte Entität</param>
        public void Update(RandomAccessMemory entity)
        {
            MySqlConnection connection = this.CreateConnection();
            MySqlCommand command = connection.CreateCommand();

            command.CommandText = "UPDATE `"+ this.GetTableName() +"` SET `Beschreibung`='" + entity.Description + "', `Speicher`=" + entity.Memory + ", `Taktrate`='"
                                + entity.ClockRate.ToString().Replace(',','.') + "', `ID_Hersteller`=" + entity.Producer.Id + " WHERE id = " + entity.Id;

            connection.Open();
            command.ExecuteNonQuery();
            connection.Close();
        }
        /// <summary>
        /// Mappt einen Datensatz aus der Datenbank auf ein Objekt vom Typ 'Arbeitsspeicher'
        /// </summary>
        /// <param name="reader">Der Datensatz, welcher gemappt wird</param>
        /// <returns>RandomAccessMemory</returns>
        protected override object MapToEntity(MySqlDataReader reader)
        {
            RandomAccessMemory ram = new RandomAccessMemory();
            ProducerDataAccess producerDataAccess = new ProducerDataAccess();

            ram.Id = Int32.Parse(reader.GetValue(0).ToString());
            ram.Description = reader.GetValue(1).ToString();
            ram.Memory = ulong.Parse(reader.GetValue(2).ToString());
            ram.ClockRate = Double.Parse(reader.GetValue(3).ToString());
            ram.Producer = producerDataAccess.GetEntityById<Producer>(Int32.Parse(reader.GetValue(4).ToString()));

            return ram;
        }
        /// <summary>
        /// Speichert ein Objekt der Entität 'Arbeitsspeicher' in der Datenbank
        /// </summary>
        /// <param name="entity">Das Objekt, welches gespeichert wird</param>
        public void Save(RandomAccessMemory entity)
        {
            MySqlConnection connection = this.CreateConnection();
            MySqlCommand command = connection.CreateCommand();

            command.CommandText = "INSERT INTO `" + this.GetTableName() + "`(`Beschreibung`, `Speicher`, `Taktrate`, "
                                + "`ID_Hersteller`) VALUES ('" + entity.Description + "'," + entity.Memory + ","
                                + entity.ClockRate.ToString().Replace(',','.') + "," + entity.Producer.Id + ")";

            connection.Open();
            command.ExecuteNonQuery();
            connection.Close();
        }
        /// <summary>
        /// Prüft die Konsistenz der Attribute der Entität 'Arbeitsspeicher'
        /// </summary>
        /// <param name="entity">Das Objekt, welches geprüft wird</param>
        /// <returns>true: Objekt Konsistent, false: Objekt fehlerhaft</returns>
        public bool CheckConsistency(RandomAccessMemory entity)
        {
            bool result = true;

            if(entity.Memory == 0)
            {
                result = false;
            }

            if (entity.ClockRate <= 0)
            {
                result = false;
            }

            return result;
        }
 /// <summary>
 /// Konstruktor: Setzt die Wert für die Initialisierung des Dialoges
 /// </summary>
 /// <param name="entity">Objekt eines Arbeitsspeichers</param>
 public CreateRAM(RandomAccessMemory entity = null)
 {
     InitializeComponent();
     this.GetProducers();
     this.RamStorageUnit.SelectedIndex = 0;
     if (entity != null)
     {
         this.entity = entity;
         this.isAvailable = true;
         this.SetAllFields();
     }
     else
     {
         this.entity = new RandomAccessMemory();
         this.isAvailable = false;
     }
 }
        public void getRandomAccessMemoryFromDatabase()
        {
            RandomAccessMemoryDataAccess dataAccess = new RandomAccessMemoryDataAccess();
            ProducerDataAccess producerDataAccess = new ProducerDataAccess();
            RandomAccessMemory ram = new RandomAccessMemory();

            ram.Description = "Dies ist ein Test";
            ram.Memory = 8000;
            ram.ClockRate = 12000;
            ram.Producer = producerDataAccess.GetLastEntity<Producer>();

            dataAccess.Save(ram);
            RandomAccessMemory dbRAM = dataAccess.GetLastEntity<RandomAccessMemory>();

            Assert.AreEqual(ram.Memory, dbRAM.Memory);
        }
        public void validateRandomAccessMemory()
        {
            RandomAccessMemory ram = new RandomAccessMemory();
            RandomAccessMemoryValidator validator = new RandomAccessMemoryValidator();

            ram.Description = "Dies ist ein Test";
            ram.Memory = 8000;
            ram.ClockRate = 12000;

            Assert.AreEqual(true, validator.CheckConsistency(ram));
        }