public void deleteMonitorFromDatabase()
        {
            MonitorDataAccess dataAccess = new MonitorDataAccess();
            Monitor monitor = dataAccess.GetLastEntity<Monitor>();

            dataAccess.Delete(monitor.Id);

            Assert.IsTrue(dataAccess.GetLastEntity<Monitor>() == null || monitor.Id == dataAccess.GetLastEntity<Monitor>().Id);
        }
        public void getMonitorFromDatabase()
        {
            MonitorDataAccess dataAccess = new MonitorDataAccess();
            ProducerDataAccess producerDataAccess = new ProducerDataAccess();
            PhysicalInterfaceDataAccess physicalInterfaceDataAccess = new PhysicalInterfaceDataAccess();
            Monitor monitor = new Monitor();

            monitor.Description = "Dies ist ein Test";
            monitor.Resolution = "1280*800";
            monitor.Inch = 24;
            monitor.AspectRatio = "16:9";
            monitor.Producer = producerDataAccess.GetLastEntity<Producer>();
            monitor.AddPhysicalInterface(new PhysicalInterfaceWithCount(physicalInterfaceDataAccess.GetLastEntity<PhysicalInterface>(), 3));

            dataAccess.Save(monitor);
            Monitor dbMonitor = dataAccess.GetLastEntity<Monitor>();

            Assert.AreEqual(monitor.Inch, dbMonitor.Inch);
        }
        /// <summary>
        /// Ruft die Informationen aus dem Formular ab und speichert sie in die Datenbank.
        /// Wirft eine Fehlermeldung, wenn die Validierung fehlschlägt.
        /// </summary>
        private void MonitorSave_Click(object sender, RoutedEventArgs e)
        {
            ProducerDataAccess dataProducer = new ProducerDataAccess();
            MonitorDataAccess monitorDataAccess = new MonitorDataAccess();
            MonitorValidator validator = new MonitorValidator();

            try
            {
                this.setEntityWithFormData(dataProducer);

                if (!validator.CheckConsistency(this.entity))
                {
                    ErrorHandler.ShowErrorMessage("Validierung fehlgeschlagen", ErrorHandler.VALIDATION_FAILED);
                }
                else
                {
                    if (this.isAvailable)
                        monitorDataAccess.Update(this.entity);
                    else
                        monitorDataAccess.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);
            }
        }