Exemple #1
0
        public void CreateTvshow()
        {
            Tvshow t2 = new Tvshow("Testserie", 99);

            Assert.IsTrue(t2.getTitle() == "Testserie");
            Assert.IsTrue(t2.getEpisodes() == 99);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Movie  m1 = new Movie("Batman", 120, 5);
            Movie  m2 = new Movie("Star Wars", 140, 4);
            Movie  m3 = new Movie("Aladdin", 90, 7);
            Tvshow s1 = new Tvshow("Lost", 120);
            Tvshow s2 = new Tvshow("Game of Thrones", 50);

            var video = new Video[] { m1, m2, m3 };

            foreach (var x in video)
            {
                Console.WriteLine("Titel: " + x.Title);
                Console.WriteLine();
            }
            m1.setWatchcount(7);
            m2.justWatched();
            m3.setWatchcount(6);
            m1.justWatched();
            m3.justWatched();

            Console.WriteLine($"Title: {m1.getTitle()} | Length: {m1.getLength()} | Watched {m1.getWatchcount()} times ");
            Console.WriteLine($"Title: {m2.getTitle()} | Length: {m2.getLength()} | Watched {m2.getWatchcount()} times ");
            Console.WriteLine($"Title: {m3.getTitle()} | Length: {m3.getLength()} | Watched {m3.getWatchcount()} times ");

            Console.WriteLine($"Title: {s1.getTitle()} | Episodes: {s1.getEpisodes()}");
            Console.WriteLine($"Title: {s2.getTitle()} | Episodes: {s2.getEpisodes()}");

            string json = JsonConvert.SerializeObject(video, Formatting.Indented);

            Console.WriteLine(json);
            using (StreamWriter file = File.CreateText(@"C:\Users\johan\oom\tasks\Task4\Task4\movie.json"))
            {
                JsonSerializer serializer = new JsonSerializer();
                serializer.Serialize(file, video);
            }

            using (StreamReader file = File.OpenText(@"C:\Users\johan\oom\tasks\Task4\Task4\movie.json"))
            {
                JsonSerializer serializer = new JsonSerializer();
                Movie[]        video2     = (Movie[])serializer.Deserialize(file, typeof(Movie[]));
                foreach (var x in video2)
                {
                    Console.WriteLine($"Title: {x.getTitle()} | Length: {x.getLength()} | Watched {x.getWatchcount()} times ");
                }
            }
            asyncMovie.asyncTask().ContinueWith((t) => Console.WriteLine()).Wait();
            Console.WriteLine("\n");

            subjectMovie.push();
        }