コード例 #1
0
ファイル: AutoTest.cs プロジェクト: ThomasWoepperer/oom
 public void CannotCreateAutowithEmptyMarke1SC()
 {
     Assert.Catch(() =>
                  {
         var x = new Auto("schwarz", "");
     });
 }
コード例 #2
0
ファイル: AutoTest.cs プロジェクト: ThomasWoepperer/oom
 public void CannotCreateAutowithEmptyColor2SC()
 {
     Assert.Catch(() =>
                  {
         var x = new Auto(null, "BMW");
     });
 }
コード例 #3
0
ファイル: AutoTest.cs プロジェクト: ThomasWoepperer/oom
 public void CannotCreateAutowithEmptyMarke1()
 {
     Assert.Catch(() =>
                  {
         var x = new Auto(10000, "schwarz", true, "");
     });
 }
コード例 #4
0
ファイル: AutoTest.cs プロジェクト: ThomasWoepperer/oom
 public void CannotCreateAutowithEmptyColor2()
 {
     Assert.Catch(() =>
                  {
         var x = new Auto(10000, null, true, "BMW");
     });
 }
コード例 #5
0
ファイル: AutoTest.cs プロジェクト: ThomasWoepperer/oom
        public void CanCreateAutoShortConstructor()
        {
            var x = new Auto("schwarz", "BMW");

            Assert.IsTrue(x.Farbe == "schwarz");
            Assert.IsTrue(x.Marke == "BMW");
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: ThomasWoepperer/oom
        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 ();
            }
        }
コード例 #7
0
ファイル: AutoTest.cs プロジェクト: ThomasWoepperer/oom
        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");
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: archermarc085/Generic
        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();
        }
コード例 #9
0
ファイル: AutoTest.cs プロジェクト: ThomasWoepperer/oom
 public void CannotCreateAutoWithNegativePrice()
 {
     Assert.Catch(() =>
                  {
         var x = new Auto(-10000, "schwarz", true, "BMW");
     });
 }