예제 #1
0
        public void ElementValueAndAttributeWithSameNameAreParsedCorrectly()
        {
            string input = "<TestClass TestElement=\"1\">" +
                            "<TestElement>2</TestElement>" +
                           "</TestClass>";
            var mapper = new Mapper<TestClass>(input);

            mapper.SetAttributeMap("TestElement", "DoubleProp");
            mapper.SetElementMap("TestElement", "DecimalProp");

            TestClass result = mapper.ParseNext();
            Assert.AreEqual(1, result.DoubleProp);
            Assert.AreEqual(2, result.DecimalProp);
        }
예제 #2
0
 public void FluentElementMappingWorksCorrectly()
 {
     string input = "<TestClass> <TestAttr>10</TestAttr> </TestClass>";
     var mapper = new Mapper<TestClass>(input);
     mapper.SetElementMap("TestAttr", x => x.IntProp);
     TestClass result = mapper.ParseNext();
     Assert.AreEqual(10, result.IntProp);
 }
예제 #3
0
 public void ParseOptionsOnElementValuesWorkCorrectly()
 {
     string input = "<TestClass> <WeirdDate>2001-05;17</WeirdDate> </TestClass>";
     var mapper = new Mapper<TestClass>(input);
     mapper.SetElementMap("WeirdDate", "Date", "yyyy-MM;dd");
     TestClass t = mapper.ParseNext();
     Assert.AreEqual(new DateTime(2001, 05, 17), t.Date);
 }