Exemplo n.º 1
0
        public static void ReadContentAsFloat8()
        {
            var reader = Utils.CreateFragmentReader("<Root> <?a?>00<!-- Comment inbetween-->9<![CDATA[9]]>.<![CDATA[9]]>99999</Root>");

            reader.PositionOnElement("Root");
            reader.Read();
            Assert.Equal(99.999999F, reader.ReadContentAs(typeof(float), null));
        }
Exemplo n.º 2
0
        public static void ReadContentAsObject6()
        {
            var reader = Utils.CreateFragmentReader("<Root>44.55</Root>");

            reader.PositionOnElement("Root");
            reader.Read();
            Assert.Equal("44.55", reader.ReadContentAsObject());
        }
Exemplo n.º 3
0
        public static void ReadContentAsTimeSpan2()
        {
            var reader = Utils.CreateFragmentReader("<Root>  P1067<!-- Comment inbetween-->51<![CDATA[9]]><![CDATA[9]]>DT2H48M5.4<?a?>775807S  </Root>");

            reader.PositionOnElement("Root");
            reader.Read();
            Assert.Equal("10675199.02:48:05.4775807", reader.ReadContentAs(typeof(TimeSpan), null).ToString());
        }
        public static void ReadContentAsDateTimeOffsetAttribute14()
        {
            var reader = Utils.CreateFragmentReader("<Root a='9999-12-31T12:59:59-10:60'/>");

            reader.PositionOnElement("Root");
            reader.MoveToAttribute("a");
            Assert.Equal(new DateTimeOffset(9999, 12, 31, 12, 59, 59, TimeSpan.FromHours(-11)).ToString(), reader.ReadContentAs(typeof(DateTimeOffset), null).ToString());
        }
        public static void ReadContentAsDateTimeOffsetAttribute17()
        {
            var reader = Utils.CreateFragmentReader("<Root a='2004-02-29T23:59:59.99999999999z  '/>");

            reader.PositionOnElement("Root");
            reader.MoveToAttribute("a");
            Assert.Equal(new DateTimeOffset(2004, 3, 1, 0, 0, 0, TimeSpan.FromHours(0)).ToString(), reader.ReadContentAs(typeof(DateTimeOffset), null).ToString());
        }
        public static void ReadContentAsDateTimeOffsetAttribute6()
        {
            var reader = Utils.CreateFragmentReader("<Root a='  2000-02-29T23:59:59+13:60  '/>");

            reader.PositionOnElement("Root");
            reader.MoveToAttribute("a");
            Assert.Equal(new DateTimeOffset(2000, 2, 29, 23, 59, 59, new TimeSpan(14, 0, 0)), reader.ReadContentAsDateTimeOffset());
        }
        public static void ReadContentAsDateTimeOffsetAttribute9()
        {
            var reader = Utils.CreateFragmentReader("<Root a='  3000-00-29T23:59:59.999999999999-13:60  '/>");

            reader.PositionOnElement("Root");
            reader.MoveToAttribute("a");
            Assert.Throws <XmlException>(() => reader.ReadContentAs(typeof(DateTime), null));
        }
Exemplo n.º 8
0
        public static void ReadContentAsDouble11()
        {
            var reader = Utils.CreateFragmentReader("<Root>  <!-- Comment inbetween-->44.<?a?>44  </Root>");

            reader.PositionOnElement("Root");
            reader.Read();
            Assert.Equal(44.44d, reader.ReadContentAs(typeof(double), null));
        }
Exemplo n.º 9
0
        public static void ReadContentAsDouble3()
        {
            var reader = Utils.CreateFragmentReader("<Root> <?a?>0<![CDATA[0]]>0<!-- Comment inbetween-->1</Root>");

            reader.PositionOnElement("Root");
            reader.Read();
            Assert.Equal(1d, reader.ReadContentAsDouble());
        }
Exemplo n.º 10
0
        public static void ReadContentAsFloat6()
        {
            var reader = Utils.CreateFragmentReader("<Root> <![CDATA[9]]>999<!-- Comment inbetween-->9.444<?a?>5<![CDATA[6]]> </Root>");

            reader.PositionOnElement("Root");
            reader.Read();
            Assert.Equal(99999.44456F, reader.ReadContentAsFloat());
        }
Exemplo n.º 11
0
        public static void ReadContentAsDouble7()
        {
            var reader = Utils.CreateFragmentReader("<Root> <![CDATA[-0]]><?a?>0<!-- Comment inbetween-->5.5 </Root>");

            reader.PositionOnElement("Root");
            reader.Read();
            Assert.Equal(-5.5d, reader.ReadContentAs(typeof(double), null));
        }
Exemplo n.º 12
0
        public static void ReadContentAsFloat5()
        {
            var reader = Utils.CreateFragmentReader("<Root> -000123<?a?>45<!-- Comment inbetween--><![CDATA[6]]> </Root>");

            reader.PositionOnElement("Root");
            reader.Read();
            Assert.Equal(-123456F, reader.ReadContentAsFloat());
        }
Exemplo n.º 13
0
        public static void ReadContentAsFloat4()
        {
            var reader = Utils.CreateFragmentReader("<Root>  5<![CDATA[6]]>.455555<!-- Comment inbetween--><![CDATA[6]]>44<?a?>  </Root>");

            reader.PositionOnElement("Root");
            reader.Read();
            Assert.Equal(56.455555644F, reader.ReadContentAsFloat());
        }
Exemplo n.º 14
0
        public static void ReadContentAsFloat9()
        {
            var reader = Utils.CreateFragmentReader("<Root>-5<![CDATA[6]]>.4<?a?>444<!-- Comment inbetween-->455<![CDATA[6]]> </Root>");

            reader.PositionOnElement("Root");
            reader.Read();
            Assert.Equal(-56.44444556F, reader.ReadContentAs(typeof(float), null));
        }
        public static void ReadContentAsDateTimeOffsetAttribute4()
        {
            var reader = Utils.CreateFragmentReader("<Root a='  0002-01-01T00:00:00+00:00  '/>");

            reader.PositionOnElement("Root");
            reader.MoveToAttribute("a");
            Assert.Equal(new DateTimeOffset(new DateTime(2, 1, 1, 0, 0, 0, DateTimeKind.Utc)), reader.ReadContentAsDateTimeOffset());
        }
Exemplo n.º 16
0
        public static void ReadContentAsDouble4()
        {
            var reader = Utils.CreateFragmentReader("<Root> <![CDATA[0]]> </Root>");

            reader.PositionOnElement("Root");
            reader.Read();
            Assert.Equal(0d, reader.ReadContentAsDouble());
        }
        public static void ReadContentAsDateTimeOffsetAttribute5()
        {
            var reader = Utils.CreateFragmentReader("<Root a='9998-12-31T12:59:59-00:00'/>");

            reader.PositionOnElement("Root");
            reader.MoveToAttribute("a");
            Assert.Equal(new DateTimeOffset(new DateTime(9998, 12, 31, 12, 59, 59, DateTimeKind.Utc)), reader.ReadContentAsDateTimeOffset());
        }
Exemplo n.º 18
0
        public static void ReadContentAsDouble5()
        {
            var reader = Utils.CreateFragmentReader("<Root><![CDATA[9]]>9<?a?>9<!-- Comment inbetween-->9.<![CDATA[9]]></Root>");

            reader.PositionOnElement("Root");
            reader.Read();
            Assert.Equal(9999.9d, reader.ReadContentAsDouble());
        }
        public static void ReadContentAsDateTimeOffsetAttribute7()
        {
            var reader = Utils.CreateFragmentReader("<Root a='  0001-01-01T00:00:00-99:99z  '/>");

            reader.PositionOnElement("Root");
            reader.MoveToAttribute("a");
            Assert.Throws <XmlException>(() => reader.ReadContentAs(typeof(DateTime), null));
        }
Exemplo n.º 20
0
        public static void ReadContentAsDouble6()
        {
            var reader = Utils.CreateFragmentReader("<Root> 44<?a?>.55<!-- Comment inbetween--> </Root>");

            reader.PositionOnElement("Root");
            reader.Read();
            Assert.Equal(44.55d, reader.ReadContentAsDouble());
        }
        public static void ReadContentAsDateTimeOffsetAttribute12()
        {
            var reader = Utils.CreateFragmentReader("<Root a='  0000Z'/>");

            reader.PositionOnElement("Root");
            reader.MoveToAttribute("a");
            Assert.Throws <XmlException>(() => reader.ReadContentAsDateTimeOffset());
        }
Exemplo n.º 22
0
        public static void ReadContentAsBooleanAttribute5()
        {
            var reader = Utils.CreateFragmentReader("<Root a='  1  '/>");

            reader.PositionOnElement("Root");
            reader.MoveToAttribute("a");
            Assert.Equal((object)true, reader.ReadContentAs(typeof(bool), null));
        }
        public static void ReadContentAsDateTimeOffsetAttribute16()
        {
            var reader = Utils.CreateFragmentReader("<Root a='  2002-01-01T12:01:01Z'/>");

            reader.PositionOnElement("Root");
            reader.MoveToAttribute("a");
            Assert.Equal(new DateTimeOffset(2002, 1, 1, 12, 1, 1, TimeSpan.FromHours(0)).ToString(), reader.ReadContentAs(typeof(DateTimeOffset), null).ToString());
        }
Exemplo n.º 24
0
        public static void ReadContentAsBooleanAttribute6()
        {
            var reader = Utils.CreateFragmentReader("<Root a=' 1 '/>");

            reader.PositionOnElement("Root");
            reader.MoveToAttribute("a");
            Assert.True(reader.ReadContentAsBoolean());
        }
Exemplo n.º 25
0
        public static void ReadContentAsObject11()
        {
            var reader = Utils.CreateFragmentReader("<Root>44.44</Root>");

            reader.PositionOnElement("Root");
            reader.Read();
            Assert.Equal("44.44", reader.ReadContentAs(typeof(object), null));
        }
        public static void ReadContentAsDateTimeOffsetAttribute19()
        {
            var reader = Utils.CreateFragmentReader("<Root a='9999-12-31T12:59:60-11:00'/>");

            reader.PositionOnElement("Root");
            reader.MoveToAttribute("a");
            Assert.Throws <XmlException>(() => reader.ReadContentAs(typeof(DateTimeOffset), null));
        }
Exemplo n.º 27
0
        public static void ReadContentAsTimeSpan1()
        {
            var reader = Utils.CreateFragmentReader("<a>2000-02-29T23:59:59+13:60</a>");

            reader.PositionOnElement("a");
            reader.Read();
            Assert.Throws <XmlException>(() => reader.ReadContentAs(typeof(TimeSpan), null));
        }
        public static void ReadContentAsDateTimeOffsetAttribute21()
        {
            var reader = Utils.CreateFragmentReader("<Root a='0001-01-01T00:00:00-15:00'/>");

            reader.PositionOnElement("Root");
            reader.MoveToAttribute("a");
            Assert.Throws <ArgumentOutOfRangeException>(() => reader.ReadContentAs(typeof(DateTimeOffset), null));
        }
Exemplo n.º 29
0
        public static void ReadContentAsTimeSpanAttribute1()
        {
            var reader = Utils.CreateFragmentReader("<Root a='   PT0S  '/>");

            reader.PositionOnElement("Root");
            reader.MoveToAttribute("a");
            Assert.Equal("00:00:00", reader.ReadContentAs(typeof(TimeSpan), null).ToString());
        }
Exemplo n.º 30
0
        public static void ReadContentAsLong6()
        {
            var reader = Utils.CreateFragmentReader("<Root> -<?a?><!-- Comment inbetween-->00045<![CDATA[5]]> </Root>");

            reader.PositionOnElement("Root");
            reader.Read();
            Assert.Equal(-455L, reader.ReadContentAsLong());
        }