Пример #1
0
        public void ToString_DropsPropertyFromJson_WhenNullValue()
        {
            var expectedJson =
                "{" + Environment.NewLine
                + "  \"title\": \"The Enemy Within\"," + Environment.NewLine
                + "  \"season\": 1," + Environment.NewLine
                + "  \"episode\": 3," + Environment.NewLine
                + "  \"airedOn\": null" + Environment.NewLine
                + "}";

            var expected = new ConfigClasses.Configuration
            {
                Title   = "The Enemy Within",
                Season  = 1,
                Episode = 3
            };

            var json = new MiqoConfig()
                       .Save(expected)
                       .ApplicationSettings()
                       .ToString();

            Assert.NotEmpty(json);

            var actual = JsonConvert.DeserializeObject <ConfigClasses.Configuration>(json);

            Assert.Null(actual.AiredOn);
            Assert.Equal(expectedJson, json);
        }
Пример #2
0
        public void ToString_CanSerializeValidJson_WhenValidConfiguration()
        {
            var expected = new ConfigClasses.Configuration
            {
                Title   = "Children of the Gods",
                Season  = 1,
                Episode = 1,
                AiredOn = new DateTime(1997, 7, 27)
            };

            var json = new MiqoConfig()
                       .Save(expected)
                       .ApplicationSettings()
                       .ToString();

            Assert.NotEmpty(json);

            var actual = JsonConvert.DeserializeObject <ConfigClasses.Configuration>(json);

            Assert.Equal(expected.Title, actual.Title);
            Assert.Equal(expected.Season, actual.Season);
            Assert.Equal(expected.Episode, actual.Episode);
            Assert.Equal(expected.AiredOn, actual.AiredOn);
        }