public void deleteDiskFromDatabase()
        {
            DiskDataAccess dataAccess = new DiskDataAccess();
            Disk disk = dataAccess.GetLastEntity<Disk>();

            dataAccess.Delete(disk.Id);

            Assert.IsTrue(dataAccess.GetLastEntity<Disk>() == null || disk.Id == dataAccess.GetLastEntity<Disk>().Id);
        }
        public void getDiskFromDatabase()
        {
            DiskDataAccess dataAccess = new DiskDataAccess();
            ProducerDataAccess producerDataAccess = new ProducerDataAccess();
            PhysicalInterfaceDataAccess physicalInterfaceDataAccess = new PhysicalInterfaceDataAccess();
            Disk hdd = new Disk();

            hdd.Description = "Dies ist ein Test";
            hdd.Capacity = 1000;
            hdd.Ssd = false;
            hdd.Inch = 3.5;
            hdd.Producer = producerDataAccess.GetLastEntity<Producer>();
            hdd.AddPhysicalInterface(new PhysicalInterfaceWithCount(physicalInterfaceDataAccess.GetLastEntity<PhysicalInterface>(), 3));

            dataAccess.Save(hdd);
            Disk dbHDD = dataAccess.GetLastEntity<Disk>();

            Assert.AreEqual(hdd.Capacity, dbHDD.Capacity);
        }
        /// <summary>
        /// Ruft die Informationen aus dem Formular ab und speichert sie in die Datenbank.
        /// Führt eine Umrechnung in MB aus und wirft eine Fehlermeldung, wenn die Validierung
        /// fehlschlägt.
        /// </summary>
        private void DiskSave_Click(object sender, RoutedEventArgs e)
        {
            ProducerDataAccess dataProducer = new ProducerDataAccess();
            DiskDataAccess diskDataAccess = new DiskDataAccess();
            DiskValidator validator = new DiskValidator();

            try
            {
                this.setEntityWithFormData(dataProducer);

                if (!validator.CheckConsistency(this.entity))
                {
                    ErrorHandler.ShowErrorMessage("Validierung fehlgeschlagen", ErrorHandler.VALIDATION_FAILED);
                }
                else
                {
                    if (this.isAvailable)
                        diskDataAccess.Update(this.entity);
                    else
                        diskDataAccess.Save(this.entity);
                    this.Close();
                }
            }
            catch (FormatException exception)
            {
                ErrorHandler.ShowErrorMessage(exception, ErrorHandler.WRONG_FORMAT);
            }
            catch (MySql.Data.MySqlClient.MySqlException exception)
            {
                ErrorHandler.ShowErrorMessage(exception, ErrorHandler.SAVE_WENT_WRONG);
            }
            catch (System.OverflowException exception)
            {
                ErrorHandler.ShowErrorMessage(exception, ErrorHandler.DATA_TOO_LONG);
            }
        }