Example #1
0
        public void TestSetFamily()
        {
            Core.Models.Font font = new Core.Models.Font();

            font.Family = "Cascadia Code";
            Assert.AreEqual("Cascadia Code", font.Family);
        }
Example #2
0
 public void TestFont()
 {
     Core.Models.Font font = new Core.Models.Font();
     Assert.AreEqual(8, font.Size);
     Assert.AreEqual(FontStyle.Regular, font.Style);
     Assert.AreEqual("sansserif", font.Family);
 }
Example #3
0
        public void TestSetSize()
        {
            Core.Models.Font font = new Core.Models.Font();
            Assert.AreEqual(8, font.Size);

            font.Size = 10;
            Assert.AreEqual(10, font.Size);
        }
Example #4
0
        public void TestSetStyle()
        {
            Core.Models.Font font = new Core.Models.Font();
            Assert.AreEqual(8, font.Size);

            font.Style = FontStyle.Italic;
            Assert.AreEqual(FontStyle.Italic, font.Style);

            font.Style = (FontStyle)88;
            Assert.AreEqual(FontStyle.Regular, font.Style, "Invalid style was not converted properly");
        }
Example #5
0
        public void TestPersistence()
        {
            Core.Models.Font font = new Core.Models.Font();

            string json = JsonSerializer.Serialize(font, jsonOptions);

            Assert.NotNull(json);
            Assert.True(json.Length > 0);

            Core.Models.Font font2 = JsonSerializer.Deserialize <Core.Models.Font>(json);
            Assert.NotNull(font2);
            Assert.Equal(font.Family, font2.Family);
            Assert.Equal(font.Size, font2.Size);
            Assert.Equal(font.Style, font2.Style);
        }
Example #6
0
        public void TestDeserialize()
        {
            // Defaults
            string json = "{\"Family\":\"Microsoft Sans Serif\",\"Style\":\"Regular\",\"Size\":8}";

            Core.Models.Font font = JsonSerializer.Deserialize <Core.Models.Font>(json, jsonOptions);
            Assert.NotNull(font);
            Assert.Equal("Microsoft Sans Serif", font.Family);
            Assert.Equal(8, font.Size);
            Assert.Equal(FontStyle.Regular, font.Style);

            // Non Defaults
            json = "{\"Family\":\"Cascadia Code\",\"Style\":\"Italic\",\"Size\":10}";
            font = JsonSerializer.Deserialize <Core.Models.Font>(json, jsonOptions);
            Assert.NotNull(font);
            Assert.Equal("Cascadia Code", font.Family);
            Assert.Equal(10, font.Size);
            Assert.Equal(FontStyle.Italic, font.Style);

            // Numeric enum value
            json = "{\"Family\":\"Microsoft Sans Serif\",\"Style\":1,\"Size\":8}";
            font = JsonSerializer.Deserialize <Core.Models.Font>(json, jsonOptions);
            Assert.NotNull(font);
            Assert.Equal(FontStyle.Bold, font.Style);

            // Camel casing
            json = "{\"family\":\"Cascadia Code\",\"style\":\"Italic\",\"size\":10}";
            font = JsonSerializer.Deserialize <Core.Models.Font>(json, jsonOptions);
            Assert.NotNull(font);
            Assert.Equal("Cascadia Code", font.Family);
            Assert.Equal(10, font.Size);
            Assert.Equal(FontStyle.Italic, font.Style);

            // Mixed casing
            json = "{\"FAMILY\":\"Cascadia Code\",\"STYLE\":\"Italic\",\"SIzE\":10}";
            font = JsonSerializer.Deserialize <Core.Models.Font>(json, jsonOptions);
            Assert.NotNull(font);
            Assert.Equal("Cascadia Code", font.Family);
            Assert.Equal(10, font.Size);
            Assert.Equal(FontStyle.Italic, font.Style);
        }