示例#1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var game1  = new Videogame("Metal Gear Solid", "Stealth", 50);
            var game2  = new Videogame("Super Mario", "Jump'n'Run", 60);
            var movie1 = new Movie("Star Wars", "SciFi", 30);
            var movie2 = new Movie("Isle of Dogs", "SciFi", 20);

            string s1 = JsonConvert.SerializeObject(game1);
            string s2 = JsonConvert.SerializeObject(game2);
            string s3 = JsonConvert.SerializeObject(movie1);
            string s4 = JsonConvert.SerializeObject(movie2);

            Console.WriteLine(s1);
            Console.WriteLine(s3);

            File.WriteAllText(@"C:\Users\Public\movie1.json", JsonConvert.SerializeObject(movie1));

            var desgame1  = JsonConvert.DeserializeObject(s1);
            var desmovie1 = JsonConvert.DeserializeObject(s3);

            Console.WriteLine(desgame1);
            Console.WriteLine(desmovie1);

            var filemovie1 = JsonConvert.DeserializeObject <Movie>(File.ReadAllText(@"C:\Users\Public\movie1.json"));

            Console.WriteLine(filemovie1);

            Console.WriteLine("Thank you!\n");
        }
示例#2
0
 public void PriceIsMinus()
 {
     Assert.Catch(() =>
     {
         var test4 = new Videogame("Super Mario", "Jump'n'Run", -30);
     }
                  );
 }
示例#3
0
 public void CannotCreateBookWithEmptyName()
 {
     Assert.Catch(() =>
     {
         var test5 = new Videogame("", "Jump'n'Run", 30);
     }
                  );
 }
示例#4
0
        public void CanUpdatePrice()
        {
            var test7 = new Videogame("Testmovie", "Testgenre", 10);

            test7.SetPrice(20);

            Assert.IsTrue(test7.Price == 20);
        }
示例#5
0
 public void CannotUpdatePrice()
 {
     Assert.Catch(() =>
     {
         var test8 = new Videogame("Super Mario", "Jump'n'Run", 10);
         test8.SetPrice(-25);
     }
                  );
 }
示例#6
0
        public void NameIsWrong()
        {
            var test3 = new Videogame("Testgame", "Action", 20);

            Assert.IsFalse(test3.Name == "Super Mario");
        }
示例#7
0
        public void NameIsNotTrue()
        {
            var test9 = new Videogame("Testagme", "Testgenre", 10);

            Assert.IsFalse(test9.Name == "Zelda");
        }