public void BoolPropertyZeroIsParsedAsFalse() { string input = "<TestClass BoolProp=\"0\" /> "; var mapper = new Mapper<TestClass>(input); TestClass result = mapper.ParseNext(); Assert.IsFalse(result.BoolProp); }
public void BoolPropertyTrueStringIsParsedAsTrue() { string input = "<TestClass BoolProp=\"true\" /> "; var mapper = new Mapper<TestClass>(input); TestClass result = mapper.ParseNext(); Assert.IsTrue(result.BoolProp); }
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); }
public void DoublePropertyParsedCorrectly() { var mapper = new Mapper<TestClass>(_input, "SampleXml"); TestClass t = mapper.ParseNext(); Assert.AreEqual(5.0, t.DoubleProp); }
public void DecimalPropertyParsedCorrectly() { var mapper = new Mapper<TestClass>(_input, "SampleXml"); TestClass t = mapper.ParseNext(); Assert.AreEqual(1.23456789, t.DecimalProp); }
public void DateTimeParsingWorksCorrectly() { var mapper = new Mapper<TestClass>(_input, "SampleXml"); TestClass t = mapper.ParseNext(); Assert.AreEqual(new DateTime(2001, 11, 16), t.Date); }
public void NamedElementPropertyParsedCorrectly() { var mapper = new Mapper<TestClass>(_input, "SampleXml"); TestClass t = mapper.ParseNext(); Assert.AreEqual(55, t.PropWithSpecifiedEelementName); }
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); }
public void PropertyUsedWithSetAttributeMapParsedCorrectly() { var mapper = new Mapper<TestClass>(_input, "SampleXml"); mapper.SetAttributeMap("BarFoo", "FooBar"); TestClass t = mapper.ParseNext(); Assert.AreEqual(1, t.FooBar); }
public void ParseNextStepsThroughTheCollectionCorrectly() { string input = "<Collection>" + "<TestClass IntProp=\"0\" /> " + "<TestClass IntProp=\"1\" /> " + "<TestClass IntProp=\"2\" /> " + "<TestClass IntProp=\"3\" /> " + "</Collection>"; var mapper = new Mapper<TestClass>(input); TestClass result = mapper.ParseNext(); Assert.AreEqual(0, result.IntProp); result = mapper.ParseNext(); Assert.AreEqual(1, result.IntProp); result = mapper.ParseNext(); Assert.AreEqual(2, result.IntProp); result = mapper.ParseNext(); Assert.AreEqual(3, result.IntProp); }
public void ParseOptionsOnAttributeValuesWorkCorrectly() { string input = "<TestClass WeirdDate=\"2001-05;17\" />"; var mapper = new Mapper<TestClass>(input); mapper.SetAttributeMap("WeirdDate", "Date", "yyyy-MM;dd"); TestClass t = mapper.ParseNext(); Assert.AreEqual(new DateTime(2001, 05, 17), t.Date); }
public void NullableDoubleParsingWorksWhenValueIsNumber() { string input = "<TestClass NullableDoubleProp=\"0.05\" /> "; var mapper = new Mapper<TestClass>(input); TestClass result = mapper.ParseNext(); Assert.AreEqual(0.05, result.NullableDoubleProp); }
public void NullableDoubleParsingReturnsNullWhenParsingDoesNotWork() { string input = "<TestClass NullableDoubleProp=\"asdf\" /> "; var mapper = new Mapper<TestClass>(input); TestClass result = mapper.ParseNext(); Assert.AreEqual(null, result.NullableDoubleProp); }
public void NotXmlMappedAttributeStopsMapping() { var mapper = new Mapper<TestClass>(_input, "SampleXml"); TestClass t = mapper.ParseNext(); Assert.AreEqual(0, t.NotMapped); }
public void FluentAttributeMappingWorksCorrectly() { string input = "<TestClass TestAttr=\"5\" /> "; var mapper = new Mapper<TestClass>(input); mapper.SetAttributeMap("TestAttr", x => x.DoubleProp); TestClass result = mapper.ParseNext(); Assert.AreEqual(null, result.NullableDoubleProp); }
public void StringPropertyParsedCorrectly() { var mapper = new Mapper<TestClass>(_input, "SampleXml"); TestClass t = mapper.ParseNext(); Assert.AreEqual("BobTheBuilder", t.StringProp); }
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); }
public void NamedAttributePropertyParsedCorrectly() { var mapper = new Mapper<TestClass>(_input, "SampleXml"); TestClass t = mapper.ParseNext(); Assert.AreEqual(99, t.PropWithSpecifiedAttributeName); }