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); }
/// <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 RamSave_Click(object sender, RoutedEventArgs e) { RandomAccessMemoryDataAccess dataRandom = new RandomAccessMemoryDataAccess(); ProducerDataAccess dataProducer = new ProducerDataAccess(); RandomAccessMemoryValidator validator = new RandomAccessMemoryValidator(); try { this.setEntityWithFormData(dataProducer); if (!validator.CheckConsistency(this.entity)) { ErrorHandler.ShowErrorMessage("Validierung fehlgeschlagen", ErrorHandler.VALIDATION_FAILED); } else { if (this.isAvailable) dataRandom.Update(this.entity); else dataRandom.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); } }