Exemple #1
0
 public void CannotCreateMusicTitleWithEmptyLengthUnit1()
 {
     Assert.Catch(() =>
     {
         var x = new MusicTitle("Interpret666", "Title333", 1010, new Length(1234, ""), 999);
     });
 }
Exemple #2
0
 public void CannotCreateMusicTitleWithNegativeLengthDuration()
 {
     Assert.Catch(() =>
     {
         var x = new MusicTitle("Interpret666", "Title333", 1010, new Length(-1234, "s"), 999);
     });
 }
Exemple #3
0
 public void CannotCreateMusicTitleWithEmptyTitle1()
 {
     Assert.Catch(() =>
     {
         var x = new MusicTitle("Interpret666", null, 1010, new Length(1234, "s"), 999);
     });
 }
Exemple #4
0
 public void CannotCreateMusicTitleWithEmptyInterpret1()
 {
     Assert.Catch(() =>
     {
         var x = new MusicTitle(null, "Title333", 1010, new Length(1234, "s"), 999);
     });
 }
Exemple #5
0
        public void CanCreateMusicTitle()
        {
            var x = new MusicTitle("Interpret666", "Title333", 1010, new Length(1234, "s"), 999);

            Assert.IsTrue(x.Interpret == "Interpret666");
            Assert.IsTrue(x.Title == "Title333");
            Assert.IsTrue(x.Year == 1010);
            Assert.IsTrue(x.Duration.Duration == 1234);
            Assert.IsTrue(x.Duration.Unit == "s");
            Assert.IsTrue(x.Price == 999);
        }
Exemple #6
0
        static void Main(string[] args)
        {
            var a = new Tonaufnahme[2];

            a[0] = new MusicTitle("test_Interpret", "test_Title", 2000, 179.2m, "s", 3.99m);
            a[1] = new Podcast("test_Publisher", "test_Title", 1999, new Length(32, "m"), 6.99m);

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

            string s = JsonConvert.SerializeObject(a, settings);

            File.WriteAllText("export.json", s);

            var textFromFile = File.ReadAllText("export.json");
            var e            = JsonConvert.DeserializeObject <Tonaufnahme[]>(textFromFile, settings);



            Console.WriteLine("String before Export:");
            Console.WriteLine(s);
            Console.WriteLine("\n\nString after Import:");
            Console.WriteLine(textFromFile);

            Console.WriteLine("\n\nCompare Titles:");
            Console.Write($"a: {a[0].Title} & {a[1].Title}");
            Console.WriteLine($"   e: {e[0].Title} & {e[1].Title}");

            Console.WriteLine("\n\nCompare Durations:");
            Console.Write($"a: {Math.Round(a[0].Duration.Duration, 1)}{a[0].Duration.Unit}");
            Console.WriteLine($"   a: {Math.Round(a[1].Duration.Duration, 1)}{a[1].Duration.Unit}");
            Console.Write($"e: {Math.Round(e[0].Duration.Duration, 1)}{e[0].Duration.Unit}");
            Console.WriteLine($"   e: {Math.Round(e[1].Duration.Duration, 1)}{e[1].Duration.Unit}");
        }