Exemple #1
0
 public void CannotCreateNetworkSwitchWithToManyPorts()
 {
     Assert.Catch(() =>
     {
         var x = new NetworkSwitch("Cisco SG 300-20", 65, 4, true, false, true, 243m, Currency.GBP);
     });
 }
Exemple #2
0
 public void CannotUpdateNetworkSwitchWithNegativePrice()
 {
     Assert.Catch(() =>
     {
         var x = new NetworkSwitch("Cisco SG 300-20", 20, 4, true, false, true, 243m, Currency.GBP);
         x.UpdatePrice(-243m, Currency.GBP);
     });
 }
Exemple #3
0
        public void CanCreateNetworkSwitch()
        {
            var x = new NetworkSwitch("Cisco SG 300-20", 20, 4, true, false, true, 243m, Currency.GBP);

            Assert.IsTrue(x.GetDescription == "Cisco SG 300-20");
            Assert.IsTrue(x.Cupper_Ports == 20);
            Assert.IsTrue(x.SFP_Ports == 4);
            Assert.IsTrue(x.Gigabit == true);
            Assert.IsTrue(x.PoE == false);
            Assert.IsTrue(x.Managed == true);
            Assert.IsTrue(x.Price == 243);
        }
Exemple #4
0
        public static void Main(string[] args)
        {
            Kamera X = new Kamera("Sony STC300IR", 3.0, 800m, Currency.EUR);
            Kamera Z = new Kamera("Geovision BL1300", 1.3, 670m, Currency.EUR);

            Console.WriteLine("Die Bezeichnung der X Kamera ist {0}.", X.GetDescription);
            Console.WriteLine("Die Bezeichnung der Z Kamera ist {0}.", Z.GetDescription);
            Console.WriteLine("Die Aufloesung der Z Kamera ist {0}MP.", Z.Aufloesung);
            X.UpdatePreis(790, Currency.EUR);
            var testX = X.GetDescription;
            var testZ = Z.GetPrice(Currency.USD);

            Console.WriteLine($"Interface Bezeichnung:{testX}");
            Console.WriteLine($"Interface Preis:{testZ}");
            Console.WriteLine("Der Preis der X Kamera ist EUR{0}.", X.Price);
            NetworkSwitch Cisco = new NetworkSwitch("Cisco SG 300-20", 20, 4, true, false, true, 243m, Currency.GBP);

            Console.WriteLine($" Feature = { Cisco.Gigabit}");

            /* Task3 */
            //array of products
            var products = new Produkt[]
            {
                new Kamera("Sony SNC-VM631", 2.3, 569m, Currency.EUR),
                new Kamera("Sony SNC-CX600", 3.0, 870m, Currency.EUR),
                new Kamera("Sony SNC-EP500", 5.0, 1200m, Currency.EUR),
                new Kamera("Sony SNC-TX800", 3.2, 775m, Currency.EUR),
                new Kamera("Sony SNC-EP550", 5.5, 1360m, Currency.EUR),
                new NetworkSwitch("Cisco SG 300-52", 52, 4, true, false, true, 599m, Currency.GBP),
                new NetworkSwitch("Cisco SG 300-26", 26, 2, false, false, true, 456m, Currency.GBP),
                new NetworkSwitch("Cisco SG 400-24", 24, 3, false, false, false, 356m, Currency.GBP),
                new NetworkSwitch("NETGEAR FS728TP-100EUS", 24, 2, false, true, true, 456m, Currency.EUR),
                new NetworkSwitch("NETGEAR FS008TP-1000EUS", 8, 2, true, true, true, 256m, Currency.EUR)
            };

            Console.WriteLine("Preis Sony SNC-CX600: {0}", products[1].Price);
            foreach (var s in products)
            {
                Console.WriteLine("Task3: {0} {1}", s.GetDescription, s.Price);
            }


            /* Task4 */
            /* Serialization*/

            Serialization.Run(products);

            /* Task 6 */

            Pull_Push_Task.Run(products);
        }
Exemple #5
0
        public static void Run(Produkt[] products)
        {
            /* Task4*/
            //Serializing

            var    test     = new NetworkSwitch("NETGEAR FS728TP-100EUS", 24, 2, false, true, true, 280m, Currency.EUR);
            string testjson = JsonConvert.SerializeObject(test);

            Console.WriteLine("Task4.1: {0}", testjson);

            var settings = new JsonSerializerSettings()
            {
                Formatting = Formatting.Indented, TypeNameHandling = TypeNameHandling.Auto
            };

            File.WriteAllText(@"G:\Studium\SS17\Objektorientierte Methoden\OOD\jsonfile.json", testjson);
            var destest = JsonConvert.DeserializeObject <NetworkSwitch>(File.ReadAllText(@"G:\Studium\SS17\Objektorientierte Methoden\OOD\jsonfile.json"), settings);

            Console.WriteLine("Task4.2: {0}", destest);

            Console.WriteLine(JsonConvert.SerializeObject(products, settings));

            var    text     = JsonConvert.SerializeObject(products, settings);
            string pathfile = @"G:\Studium\SS17\Objektorientierte Methoden\OOD";
            var    filename = Path.Combine(pathfile, "products.json");

            File.WriteAllText(filename, text);


            var textFromFile     = File.ReadAllText(filename);
            var productsFromFile = JsonConvert.DeserializeObject <Produkt[]>(textFromFile, settings);
            var currency         = Currency.EUR;

            foreach (var x in productsFromFile)
            {
                Console.WriteLine($"{x.GetDescription}, {x.Price}, {currency}");
            }
        }