Example #1
0
        public void PropertiesDeserializationTest()
        {
            var loader       = TypedObjectLoader.Create <TestData>();
            var loadedObject = loader(new Dictionary <string, string>
            {
                { "A", "22" },
                { "B", "This is it." },
                { "C", "2017-05-09 12:13:45" },
                { "D", "666" },
                { "E", "124.55555" },
                { "F", "2017-04-20 22:33:44" }
            });

            Assert.That(loadedObject, Is.EqualTo(new TestData
            {
                A = 22,
                B = "This is it.",
                C = DateTime.Parse("2017-05-09 12:13:45", CultureInfo.InvariantCulture),
                D = 666,
                E = 124.55555,
                F = DateTime.Parse("2017-04-20 22:33:44", CultureInfo.InvariantCulture)
            }));
        }
Example #2
0
        public void EmptyPropertiesDeserializationTest()
        {
            var loader = TypedObjectLoader.Create <TestData>();

            var loadedObject = loader(new Dictionary <string, string>
            {
                { "A", "" },
                { "B", "" },
                { "C", "" },
                { "D", "" },
                { "E", "" },
                { "F", "" }
            });

            Assert.That(loadedObject, Is.EqualTo(new TestData
            {
                A = 0,
                B = "",
                C = null,
                D = null,
                E = null,
                F = new DateTime()
            }));
        }