public void UpdateKundeTest()
        {
            using (AutoReservationEntities context = new AutoReservationEntities())
            {
                TestEnvironmentHelper.InitializeTestData();

                AutoReservationBusinessComponent arbc = new AutoReservationBusinessComponent();

                var res = (from kunde in context.Kunden select kunde).FirstOrDefault().Id;

                Kunde kundeOriginal = arbc.GetKunde(res);
                Kunde kundeModified = arbc.GetKunde(res);

                kundeModified.Nachname = "Geiser";
                arbc.EditKunde(kundeOriginal, kundeModified);

                Assert.AreEqual(kundeOriginal.Nachname, kundeModified.Nachname, "UpdateKundeTest: Kunden sind nicht gleich nach Update");
            }
        }
 public void DeleteKundeTest()
 {
     TestEnvironmentHelper.InitializeTestData();
     AutoReservationBusinessComponent autoReservation = new AutoReservationBusinessComponent();
     int count = autoReservation.GetKunden().Count;
     Kunde delete = autoReservation.GetKunden()[0];
     int id = delete.Id;
     autoReservation.DeleteKunde(delete);
     Assert.AreEqual(count - 1, autoReservation.GetKunden().Count);
     Assert.IsNull(autoReservation.GetKunde(id));
 }
 public void GetKundeByIdTest()
 {
     TestEnvironmentHelper.InitializeTestData();
     AutoReservationBusinessComponent autoReservation = new AutoReservationBusinessComponent();
     IList<Kunde> kunden = autoReservation.GetKunden();
     Kunde first = kunden[0];
     int id = first.Id;
     Kunde kundeById = autoReservation.GetKunde(id);
     Assert.AreEqual(first, kundeById);
 }
        public void UpdateKundeTest()
        {
            string modifiedVorname = "Test Vorname";

            TestEnvironmentHelper.InitializeTestData();
            AutoReservationBusinessComponent autoReservation = new AutoReservationBusinessComponent();
            IList<Kunde> kunden = autoReservation.GetKunden();
            Kunde modified = kunden[0];
            Kunde original = Kunde.CreateKunde(modified.Id, modified.Nachname, modified.Vorname, modified.Geburtsdatum);

            modified.Vorname = modifiedVorname;
            int idFromUpdatedKunde = modified.Id;
            autoReservation.UpdateKunde(modified, original);
            Kunde modifiedFetchedFromDb = autoReservation.GetKunde(idFromUpdatedKunde);
            Assert.AreEqual(modified.Vorname, modifiedFetchedFromDb.Vorname);
        }