1 // Licensed to the .NET Foundation under one or more agreements. 2 // The .NET Foundation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using Xunit; 6 7 namespace System.Xml.Tests 8 { 9 public class StringAttributeTests 10 { 11 [Fact] ReadContentAsStringAttribute1()12 public static void ReadContentAsStringAttribute1() 13 { 14 var reader = Utils.CreateFragmentReader("<Root a='-56.455'/>"); 15 reader.PositionOnElement("Root"); 16 reader.MoveToAttribute("a"); 17 Assert.Equal("-56.455", reader.ReadContentAs(typeof(String), null)); 18 } 19 20 [Fact] ReadContentAsStringAttribute10()21 public static void ReadContentAsStringAttribute10() 22 { 23 var reader = Utils.CreateFragmentReader("<Root a='0'/>"); 24 reader.PositionOnElement("Root"); 25 reader.MoveToAttribute("a"); 26 Assert.Equal("0", reader.ReadContentAs(typeof(String), null)); 27 } 28 29 [Fact] ReadContentAsStringAttribute11()30 public static void ReadContentAsStringAttribute11() 31 { 32 var reader = Utils.CreateFragmentReader("<Root a='0099.99'/>"); 33 reader.PositionOnElement("Root"); 34 reader.MoveToAttribute("a"); 35 Assert.Equal("0099.99", reader.ReadContentAs(typeof(String), null)); 36 } 37 38 [Fact] ReadContentAsStringAttribute12()39 public static void ReadContentAsStringAttribute12() 40 { 41 var reader = Utils.CreateFragmentReader("<Root a='-56.44'/>"); 42 reader.PositionOnElement("Root"); 43 reader.MoveToAttribute("a"); 44 Assert.Equal("-56.44", reader.ReadContentAs(typeof(String), null)); 45 } 46 47 [Fact] ReadContentAsStringAttribute2()48 public static void ReadContentAsStringAttribute2() 49 { 50 var reader = Utils.CreateFragmentReader("<Root a='-000123456'/>"); 51 reader.PositionOnElement("Root"); 52 reader.MoveToAttribute("a"); 53 Assert.Equal("-000123456", reader.ReadContentAs(typeof(String), null)); 54 } 55 56 [Fact] ReadContentAsStringAttribute3()57 public static void ReadContentAsStringAttribute3() 58 { 59 var reader = Utils.CreateFragmentReader("<Root a='99999.44456'/>"); 60 reader.PositionOnElement("Root"); 61 reader.MoveToAttribute("a"); 62 Assert.Equal("99999.44456", reader.ReadContentAs(typeof(String), null)); 63 } 64 65 [Fact] ReadContentAsStringAttribute4()66 public static void ReadContentAsStringAttribute4() 67 { 68 var reader = Utils.CreateFragmentReader("<Root a='0'/>"); 69 reader.PositionOnElement("Root"); 70 reader.MoveToAttribute("a"); 71 Assert.Equal("0", reader.ReadContentAsString()); 72 } 73 74 [Fact] ReadContentAsStringAttribute5()75 public static void ReadContentAsStringAttribute5() 76 { 77 var reader = Utils.CreateFragmentReader("<Root a='0099.99'/>"); 78 reader.PositionOnElement("Root"); 79 reader.MoveToAttribute("a"); 80 Assert.Equal("0099.99", reader.ReadContentAsString()); 81 } 82 83 [Fact] ReadContentAsStringAttribute6()84 public static void ReadContentAsStringAttribute6() 85 { 86 var reader = Utils.CreateFragmentReader("<Root a='-56.44'/>"); 87 reader.PositionOnElement("Root"); 88 reader.MoveToAttribute("a"); 89 Assert.Equal("-56.44", reader.ReadContentAsString()); 90 } 91 92 [Fact] ReadContentAsStringAttribute7()93 public static void ReadContentAsStringAttribute7() 94 { 95 var reader = Utils.CreateFragmentReader("<Root a='-56.455'/>"); 96 reader.PositionOnElement("Root"); 97 reader.MoveToAttribute("a"); 98 Assert.Equal("-56.455", reader.ReadContentAsString()); 99 } 100 101 [Fact] ReadContentAsStringAttribute8()102 public static void ReadContentAsStringAttribute8() 103 { 104 var reader = Utils.CreateFragmentReader("<Root a='-000123456'/>"); 105 reader.PositionOnElement("Root"); 106 reader.MoveToAttribute("a"); 107 Assert.Equal("-000123456", reader.ReadContentAsString()); 108 } 109 110 [Fact] ReadContentAsStringAttribute9()111 public static void ReadContentAsStringAttribute9() 112 { 113 var reader = Utils.CreateFragmentReader("<Root a='99999.44456'/>"); 114 reader.PositionOnElement("Root"); 115 reader.MoveToAttribute("a"); 116 Assert.Equal("99999.44456", reader.ReadContentAsString()); 117 } 118 } 119 } 120