diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2005-12-12 15:21:09 +0300 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2005-12-12 15:21:09 +0300 |
commit | 79479e664366a931ab4903bb5cc48227cbbcd893 (patch) | |
tree | 2d76329c01ae1403481d030a7477439b4e62042a /mcs/class/System.XML | |
parent | fb17c20276dba64233af0205bc8ed943b134261e (diff) |
2005-12-12 Atsushi Enomoto <atsushi@ximian.com>
* XPathNavigator.cs : removed some MonoTODOs.
* XPathNavigatorTests.cs : added tests for ValueAsXxx properties.
svn path=/trunk/mcs/; revision=54233
Diffstat (limited to 'mcs/class/System.XML')
4 files changed, 138 insertions, 12 deletions
diff --git a/mcs/class/System.XML/System.Xml.XPath/ChangeLog b/mcs/class/System.XML/System.Xml.XPath/ChangeLog index 3804dc34dce..a1a1a85ee00 100644 --- a/mcs/class/System.XML/System.Xml.XPath/ChangeLog +++ b/mcs/class/System.XML/System.Xml.XPath/ChangeLog @@ -1,3 +1,7 @@ +2005-12-12 Atsushi Enomoto <atsushi@ximian.com> + + * XPathNavigator.cs : removed some MonoTODOs. + 2005-12-08 Atsushi Enomoto <atsushi@ximian.com> * XPathDocument.cs : garbage cleanup. diff --git a/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs b/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs index 4af1cf755f8..da0b83e65e5 100644 --- a/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs +++ b/mcs/class/System.XML/System.Xml.XPath/XPathNavigator.cs @@ -957,32 +957,26 @@ namespace System.Xml.XPath get { throw new NotImplementedException (); } } - [MonoTODO] public override bool ValueAsBoolean { get { return XQueryConvert.StringToBoolean (Value); } } - [MonoTODO] public override DateTime ValueAsDateTime { get { return XmlConvert.ToDateTime (Value); } } - [MonoTODO] public override double ValueAsDouble { get { return XQueryConvert.StringToDouble (Value); } } - [MonoTODO] public override int ValueAsInt { get { return XQueryConvert.StringToInt (Value); } } - [MonoTODO] public override long ValueAsLong { get { return XQueryConvert.StringToInteger (Value); } } - [MonoTODO] public override Type ValueType { get { return SchemaInfo != null && @@ -1002,12 +996,6 @@ namespace System.Xml.XPath } } - - - - - - private XmlReader CreateFragmentReader (string fragment) { return new XmlTextReader (fragment, XmlNodeType.Element, new XmlParserContext (NameTable, null, null, XmlSpace.None)); diff --git a/mcs/class/System.XML/Test/System.Xml.XPath/ChangeLog b/mcs/class/System.XML/Test/System.Xml.XPath/ChangeLog index 3c5ba02d630..38228e47640 100644 --- a/mcs/class/System.XML/Test/System.Xml.XPath/ChangeLog +++ b/mcs/class/System.XML/Test/System.Xml.XPath/ChangeLog @@ -1,3 +1,7 @@ +2005-12-12 Atsushi Enomoto <atsushi@ximian.com> + + * XPathNavigatorTests.cs : added tests for ValueAsXxx properties. + 2005-10-23 Atsushi Enomoto <atsushi@ximian.com> * XPathNavigatorCommonTests.cs, XPathNavigatorTests.cs, diff --git a/mcs/class/System.XML/Test/System.Xml.XPath/XPathNavigatorTests.cs b/mcs/class/System.XML/Test/System.Xml.XPath/XPathNavigatorTests.cs index dfe0840384c..484012241ba 100644 --- a/mcs/class/System.XML/Test/System.Xml.XPath/XPathNavigatorTests.cs +++ b/mcs/class/System.XML/Test/System.Xml.XPath/XPathNavigatorTests.cs @@ -283,5 +283,135 @@ namespace MonoTests.System.Xml AssertEquals ("#2", XPathNodeType.SignificantWhitespace, nav.NodeType); } + +#if NET_2_0 + [Test] + public void ValueAsBoolean () + { + string xml = "<root>1</root>"; + XmlDocument doc = new XmlDocument (); + doc.LoadXml (xml); + XPathNavigator nav = doc.CreateNavigator (); + nav.MoveToFirstChild (); + AssertEquals ("#1", true, nav.ValueAsBoolean); + nav.MoveToFirstChild (); + AssertEquals ("#2", true, nav.ValueAsBoolean); + } + + [Test] + [ExpectedException (typeof (FormatException))] + public void ValueAsBooleanFail () + { + string xml = "<root>1.0</root>"; + XmlDocument doc = new XmlDocument (); + doc.LoadXml (xml); + XPathNavigator nav = doc.CreateNavigator (); + nav.MoveToFirstChild (); + bool i = nav.ValueAsBoolean; + } + + [Test] + public void ValueAsDateTime () + { + DateTime time = new DateTime (2005, 12, 13); + string xml = "<root>2005-12-13</root>"; + XmlDocument doc = new XmlDocument (); + doc.LoadXml (xml); + XPathNavigator nav = doc.CreateNavigator (); + nav.MoveToFirstChild (); + AssertEquals ("#1", time, nav.ValueAsDateTime); + nav.MoveToFirstChild (); + AssertEquals ("#2", time, nav.ValueAsDateTime); + } + + [Test] + [ExpectedException (typeof (FormatException))] + public void ValueAsDateTimeFail () + { + string xml = "<root>dating time</root>"; + XmlDocument doc = new XmlDocument (); + doc.LoadXml (xml); + XPathNavigator nav = doc.CreateNavigator (); + nav.MoveToFirstChild (); + DateTime time = nav.ValueAsDateTime; + } + + [Test] + public void ValueAsDouble () + { + string xml = "<root>3.14159265359</root>"; + XmlDocument doc = new XmlDocument (); + doc.LoadXml (xml); + XPathNavigator nav = doc.CreateNavigator (); + nav.MoveToFirstChild (); + AssertEquals ("#1", 3.14159265359, nav.ValueAsDouble); + nav.MoveToFirstChild (); + AssertEquals ("#2", 3.14159265359, nav.ValueAsDouble); + } + + [Test] + [ExpectedException (typeof (FormatException))] + public void ValueAsDoubleFail () + { + string xml = "<root>Double Dealer</root>"; + XmlDocument doc = new XmlDocument (); + doc.LoadXml (xml); + XPathNavigator nav = doc.CreateNavigator (); + nav.MoveToFirstChild (); + Double dealer = nav.ValueAsDouble; + } + + [Test] + public void ValueAsInt () + { + string xml = "<root>1</root>"; + XmlDocument doc = new XmlDocument (); + doc.LoadXml (xml); + XPathNavigator nav = doc.CreateNavigator (); + nav.MoveToFirstChild (); + AssertEquals ("#1", 1, nav.ValueAsInt); + nav.MoveToFirstChild (); + AssertEquals ("#2", 1, nav.ValueAsInt); + } + + [Test] + // Here, it seems to be using XQueryConvert (whatever was called) + [ExpectedException (typeof (FormatException))] + public void ValueAsIntFail () + { + string xml = "<root>1.0</root>"; + XmlDocument doc = new XmlDocument (); + doc.LoadXml (xml); + XPathNavigator nav = doc.CreateNavigator (); + nav.MoveToFirstChild (); + int i = nav.ValueAsInt; + } + + [Test] + public void ValueAsLong () + { + string xml = "<root>10000000000000000</root>"; + XmlDocument doc = new XmlDocument (); + doc.LoadXml (xml); + XPathNavigator nav = doc.CreateNavigator (); + nav.MoveToFirstChild (); + AssertEquals ("#1", 10000000000000000, nav.ValueAsLong); + nav.MoveToFirstChild (); + AssertEquals ("#2", 10000000000000000, nav.ValueAsLong); + } + + [Test] + // Here, it seems to be using XQueryConvert (whatever was called) + [ExpectedException (typeof (FormatException))] + public void ValueAsLongFail () + { + string xml = "<root>0x10000000000000000</root>"; + XmlDocument doc = new XmlDocument (); + doc.LoadXml (xml); + XPathNavigator nav = doc.CreateNavigator (); + nav.MoveToFirstChild (); + long l = nav.ValueAsLong; + } +#endif } } |