public void UpdateAutoTest() { using (AutoReservationEntities context = new AutoReservationEntities()) { TestEnvironmentHelper.InitializeTestData(); AutoReservationBusinessComponent arbc = new AutoReservationBusinessComponent(); var res = (from auto in context.Autos select auto).FirstOrDefault().Id; //Console.WriteLine("Abgefragte Id:" + res); Auto autoOriginal = arbc.GetAuto(res); Auto autoModified = arbc.GetAuto(res); //Console.WriteLine("Marke original vorher:" + autoOriginal.Marke); //Console.WriteLine("Marke modified vorher:" + autoModified.Marke); autoModified.Marke = "Fiat Punto Abart"; arbc.EditAuto(autoOriginal, autoModified); //Auto autoControl = arbc.GetAuto(res); //Console.WriteLine("Marke original nachher:" + autoOriginal.Marke); //Console.WriteLine("Marke control nachher:" + autoControl.Marke); //Console.WriteLine("Marke modified nachher:" + autoModified.Marke); Assert.AreEqual(autoOriginal.Marke, autoModified.Marke, "UpdateAutoTest: Autos sind nicht gleich nach Update"); } }
public void GetAutoByIdTest() { TestEnvironmentHelper.InitializeTestData(); AutoReservationBusinessComponent autoReservation = new AutoReservationBusinessComponent(); IList<Auto> autos = autoReservation.GetAutos(); Auto first = autos[0]; int id = first.Id; Auto autoById = autoReservation.GetAuto(id); Assert.IsTrue(first.Equals(autoById)); }
public void DeleteAutoTest() { TestEnvironmentHelper.InitializeTestData(); AutoReservationBusinessComponent autoReservation = new AutoReservationBusinessComponent(); int count = autoReservation.GetAutos().Count; Auto delete = autoReservation.GetAutos()[0]; int id = delete.Id; autoReservation.DeleteAuto(delete); Assert.AreEqual(count - 1, autoReservation.GetAutos().Count); Assert.IsNull(autoReservation.GetAuto(id)); }
public void UpdateAutoTest() { string modifiedBrand = "Test Marke"; TestEnvironmentHelper.InitializeTestData(); AutoReservationBusinessComponent autoReservation = new AutoReservationBusinessComponent(); IList<Auto> autos = autoReservation.GetAutos(); var standartAuto = from a in autos where a.Marke == "Fiat Punto" select a; Auto fiat = standartAuto.FirstOrDefault(); Auto original = StandardAuto.CreateStandardAuto(fiat.Id, fiat.Marke, fiat.Tagestarif); Auto modified = autos[0]; int modifiedAutoId = modified.Id; modified.Marke = modifiedBrand; autoReservation.UpdateAuto(modified, original); Auto fetchedFromDb = autoReservation.GetAuto(modifiedAutoId); Assert.AreEqual(modified.Marke, fetchedFromDb.Marke); }