public void CannotCreateAutowithEmptyMarke1SC() { Assert.Catch(() => { var x = new Auto("schwarz", ""); }); }
public void CannotCreateAutowithEmptyColor2SC() { Assert.Catch(() => { var x = new Auto(null, "BMW"); }); }
public void CannotCreateAutowithEmptyMarke1() { Assert.Catch(() => { var x = new Auto(10000, "schwarz", true, ""); }); }
public void CannotCreateAutowithEmptyColor2() { Assert.Catch(() => { var x = new Auto(10000, null, true, "BMW"); }); }
public void CanCreateAutoShortConstructor() { var x = new Auto("schwarz", "BMW"); Assert.IsTrue(x.Farbe == "schwarz"); Assert.IsTrue(x.Marke == "BMW"); }
public static void Main(string[] args) { string json = ""; var fahrzeuge = new IAusgabe[] { new Auto(10000, "schwarz", true, "BMW"), new Auto(30000, "rot", true, "Audi"), new Auto("silber","Mercedes"), new Auto("gelb", "Ferrari"), new Motorrad(8000, "Mazda", "grün"), new Motorrad(30000, "Lamborghini", "gelb"), new Motorrad("Ferrari", "rot"), new Motorrad("Mitsubishi", "grün"), }; var Autos = new Auto[] { new Auto(10000, "schwarz", true, "BMWA"), new Auto(30000, "rot", true, "Audi"), new Auto("silber","Mercedes"), new Auto("gelb", "Ferrari") }; foreach (var x in fahrzeuge) { json = JsonConvert.SerializeObject (x); x.printProperties (); Console.WriteLine (json); Console.WriteLine(""); } using (StreamWriter file = File.CreateText(@"./Auto.json")) { JsonSerializer serializer = new JsonSerializer (); List<Auto> autoin = new List<Auto> (); foreach (var x in Autos) { autoin.Add (x); } serializer.Serialize (file, autoin); } List<Auto> auto1 = new List<Auto>(); using (StreamReader file2 = File.OpenText(@"./Auto.json")) { JsonSerializer serializer2 = new JsonSerializer(); // List<Auto> auto1= new List<Auto>(); auto1 = (List<Auto>)serializer2.Deserialize(file2, typeof(List<Auto>)); //auto1.printProperties (); } foreach (Auto x in auto1) { x.printProperties (); } }
public void CanCreateAutoFullConstructor() { var x = new Auto(10000, "schwarz", true, "BMW"); Assert.IsTrue(x.Preis == 10000); Assert.IsTrue(x.Farbe == "schwarz"); Assert.IsTrue(x.hatAllrad == true); Assert.IsTrue(x.Marke == "BMW"); }
static void Main(string[] args) { Auto auto = new Auto(); Auto auto1 = new Auto(); MyList<Auto> myauto = new MyList<Auto>(); myauto.Add(auto); myauto[0].Name = "Audi"; myauto.Add(auto1); myauto.Add(new Auto()); // myauto.Remove(1); //Console.WriteLine(myauto[1].Name); myauto.GetArray<Auto>(); Console.WriteLine(myauto.Count); Console.ReadLine(); }
public void CannotCreateAutoWithNegativePrice() { Assert.Catch(() => { var x = new Auto(-10000, "schwarz", true, "BMW"); }); }