public void TestEnumNullable() { var service = this.GetService(); var result = service.GetRoot(XmlValue.CreateNullable <MyEnum?>("MyEnum", MyEnum.Other)); Assert.AreEqual("<MyEnum>Other</MyEnum>", result); }
public void TestEnumNullableNull() { var service = this.GetService(); var result = service.GetRoot(XmlValue.CreateNullable <MyEnum?>("MyEnum", null)); Assert.AreEqual("<MyEnum xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\" />", result); }
public void TestDateTimeNullable() { var service = this.GetService(); var result = service.GetRoot(XmlValue.CreateNullable <DateTime?>("DateTime", new DateTime(1990, 12, 12))); Assert.AreEqual("<DateTime>12/12/1990 00:00:00</DateTime>", result); }
public void TestGuidNullable() { var service = this.GetService(); var result = service.GetRoot(XmlValue.CreateNullable <Guid?>("Guid", new Guid("344ac1a2-9613-44d7-b64c-8d45b4585176"))); Assert.AreEqual("<Guid>344ac1a2-9613-44d7-b64c-8d45b4585176</Guid>", result); }
public void TestArrayOfBoolNullablesWithNulls() { var service = this.GetService(); var values = new bool?[] { true, null }; var result = service.GetRoot(new XmlArray("ArrayOfBoolean").Add(XmlValue.CreateNullable("Boolean", values[0])).Add(XmlValue.CreateNullable("Boolean", values[1]))); Assert.AreEqual("<ArrayOfBoolean xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Boolean>true</Boolean><Boolean xsi:nil=\"true\" /></ArrayOfBoolean>", result); }
public void TestArrayOfBoolNullables() { var service = this.GetService(); var values = new bool?[] { true, false }; var result = service.GetRoot(new XmlArray("ArrayOfBoolean").Add(XmlValue.CreateNullable("Boolean", values[0])).Add(XmlValue.CreateNullable("Boolean", values[1]))); Assert.AreEqual("<ArrayOfBoolean><Boolean>true</Boolean><Boolean>false</Boolean></ArrayOfBoolean>", result); }
public void TestBoolNullable() { var service = this.GetService(); var resultTrue = service.GetRoot(XmlValue.CreateNullable <bool?>("Boolean", true)); var resultFalse = service.GetRoot(XmlValue.CreateNullable <bool?>("Boolean", false)); Assert.AreEqual("<Boolean>true</Boolean>", resultTrue); Assert.AreEqual("<Boolean>false</Boolean>", resultFalse); }
public void TestCreateNullable_WithNull() { var key = "MyNullable"; var value = 10; var result = XmlValue.CreateNullable <int?>(key, value); Assert.AreEqual(key, result.NodeName); Assert.AreEqual(value, result.Value); Assert.AreEqual(XmlValueType.Nullable, result.ValueType); }
public void TestSetNilNullable() { var key = "MyNullable"; var key2 = "MyNullable"; var value = 10; var result = XmlValue.CreateNullable <int?>(key, value); Assert.IsFalse(result.IsNil); var result2 = XmlValue.CreateNullable <int?>(key2, null); Assert.IsTrue(result2.IsNil); }
public void TestArrayOfNullablesNull() { var service = this.GetService(); Int16?[] MyInt16 = new Int16?[] { 10, null }; Int32?[] MyInt32 = new Int32?[] { 10, null }; Int64?[] MyInt64 = new Int64?[] { 10, null }; Byte?[] MyByte = new Byte?[] { 201, null }; SByte?[] MySByte = new SByte?[] { -102, null }; UInt16?[] MyUInt16 = new UInt16?[] { 10, null }; UInt32?[] MyUInt32 = new UInt32?[] { 10, null }; UInt64?[] MyUInt64 = new UInt64?[] { 10, null }; Decimal?[] MyDec = new Decimal?[] { 10.5M, null }; Double?[] MyDouble = new Double?[] { 10.5, null }; Single?[] MySingle = new Single?[] { 10.5F, null }; var xmlInt16 = new XmlArray("ArrayOfInt16").Add(XmlValue.CreateNullable("Int16", MyInt16[0])).Add(XmlValue.CreateNullable("Int16", MyInt16[1])); var xmlInt32 = new XmlArray("ArrayOfInt32").Add(XmlValue.CreateNullable("Int32", MyInt32[0])).Add(XmlValue.CreateNullable("Int32", MyInt32[1])); var xmlInt64 = new XmlArray("ArrayOfInt64").Add(XmlValue.CreateNullable("Int64", MyInt32[0])).Add(XmlValue.CreateNullable("Int64", MyInt64[1])); var xmlByte = new XmlArray("ArrayOfByte").Add(XmlValue.CreateNullable("Byte", MyByte[0])).Add(XmlValue.CreateNullable("Byte", MyByte[1])); var xmlSByte = new XmlArray("ArrayOfSByte").Add(XmlValue.CreateNullable("SByte", MySByte[0])).Add(XmlValue.CreateNullable("SByte", MySByte[1])); var xmlUInt16 = new XmlArray("ArrayOfUInt16").Add(XmlValue.CreateNullable("UInt16", MyInt16[0])).Add(XmlValue.CreateNullable("UInt16", MyInt16[1])); var xmlUInt32 = new XmlArray("ArrayOfUInt32").Add(XmlValue.CreateNullable("UInt32", MyInt32[0])).Add(XmlValue.CreateNullable("UInt32", MyInt32[1])); var xmlUInt64 = new XmlArray("ArrayOfUInt64").Add(XmlValue.CreateNullable("UInt64", MyInt32[0])).Add(XmlValue.CreateNullable("UInt64", MyInt64[1])); var xmlMyDec = new XmlArray("ArrayOfDecimal").Add(XmlValue.CreateNullable("Decimal", MyDec[0])).Add(XmlValue.CreateNullable("Decimal", MyDec[1])); var xmlMyDouble = new XmlArray("ArrayOfDouble").Add(XmlValue.CreateNullable("Double", MyDouble[0])).Add(XmlValue.CreateNullable("Double", MyDouble[1])); var xmlMySingle = new XmlArray("ArrayOfSingle").Add(XmlValue.CreateNullable("Single", MySingle[0])).Add(XmlValue.CreateNullable("Single", MySingle[1])); var resultInt16 = service.GetRoot(xmlInt16); var resultInt32 = service.GetRoot(xmlInt32); var resultInt64 = service.GetRoot(xmlInt64); var resultByte = service.GetRoot(xmlByte); var resultSByte = service.GetRoot(xmlSByte); var resultUInt16 = service.GetRoot(xmlUInt16); var resultUInt32 = service.GetRoot(xmlUInt32); var resultUInt64 = service.GetRoot(xmlUInt64); var resultMyDec = service.GetRoot(xmlMyDec); var resultMyDouble = service.GetRoot(xmlMyDouble); var resultMySingle = service.GetRoot(xmlMySingle); Assert.AreEqual("<ArrayOfInt16 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Int16>10</Int16><Int16 xsi:nil=\"true\" /></ArrayOfInt16>", resultInt16); Assert.AreEqual("<ArrayOfInt32 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Int32>10</Int32><Int32 xsi:nil=\"true\" /></ArrayOfInt32>", resultInt32); Assert.AreEqual("<ArrayOfInt64 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Int64>10</Int64><Int64 xsi:nil=\"true\" /></ArrayOfInt64>", resultInt64); Assert.AreEqual("<ArrayOfByte xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Byte>201</Byte><Byte xsi:nil=\"true\" /></ArrayOfByte>", resultByte); Assert.AreEqual("<ArrayOfSByte xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><SByte>-102</SByte><SByte xsi:nil=\"true\" /></ArrayOfSByte>", resultSByte); Assert.AreEqual("<ArrayOfUInt16 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><UInt16>10</UInt16><UInt16 xsi:nil=\"true\" /></ArrayOfUInt16>", resultUInt16); Assert.AreEqual("<ArrayOfUInt32 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><UInt32>10</UInt32><UInt32 xsi:nil=\"true\" /></ArrayOfUInt32>", resultUInt32); Assert.AreEqual("<ArrayOfUInt64 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><UInt64>10</UInt64><UInt64 xsi:nil=\"true\" /></ArrayOfUInt64>", resultUInt64); Assert.AreEqual("<ArrayOfDecimal xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Decimal>10.5</Decimal><Decimal xsi:nil=\"true\" /></ArrayOfDecimal>", resultMyDec); Assert.AreEqual("<ArrayOfDouble xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Double>10.5</Double><Double xsi:nil=\"true\" /></ArrayOfDouble>", resultMyDouble); Assert.AreEqual("<ArrayOfSingle xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Single>10.5</Single><Single xsi:nil=\"true\" /></ArrayOfSingle>", resultMySingle); }
public void TestArrayOfNullables() { var service = this.GetService(); Int16?[] MyInt16 = new Int16?[] { 10, 20 }; Int32?[] MyInt32 = new Int32?[] { 10, 20 }; Int64?[] MyInt64 = new Int64?[] { 10, 20 }; Byte?[] MyByte = new Byte?[] { 201, 202 }; SByte?[] MySByte = new SByte?[] { -102, 101 }; UInt16?[] MyUInt16 = new UInt16?[] { 10, 20 }; UInt32?[] MyUInt32 = new UInt32?[] { 10, 20 }; UInt64?[] MyUInt64 = new UInt64?[] { 10, 20 }; Decimal?[] MyDec = new Decimal?[] { 10.5M, 11.5M }; Double?[] MyDouble = new Double?[] { 10.5, 11.5 }; Single?[] MySingle = new Single?[] { 10.5F, 11.5F }; var xmlInt16 = new XmlArray("ArrayOfInt16").Add(XmlValue.CreateNullable("Int16", MyInt16[0])).Add(XmlValue.CreateNullable("Int16", MyInt16[1])); var xmlInt32 = new XmlArray("ArrayOfInt32").Add(XmlValue.CreateNullable("Int32", MyInt32[0])).Add(XmlValue.CreateNullable("Int32", MyInt32[1])); var xmlInt64 = new XmlArray("ArrayOfInt64").Add(XmlValue.CreateNullable("Int64", MyInt32[0])).Add(XmlValue.CreateNullable("Int64", MyInt64[1])); var xmlByte = new XmlArray("ArrayOfByte").Add(XmlValue.CreateNullable("Byte", MyByte[0])).Add(XmlValue.CreateNullable("Byte", MyByte[1])); var xmlSByte = new XmlArray("ArrayOfSByte").Add(XmlValue.CreateNullable("SByte", MySByte[0])).Add(XmlValue.CreateNullable("SByte", MySByte[1])); var xmlUInt16 = new XmlArray("ArrayOfUInt16").Add(XmlValue.CreateNullable("UInt16", MyInt16[0])).Add(XmlValue.CreateNullable("UInt16", MyInt16[1])); var xmlUInt32 = new XmlArray("ArrayOfUInt32").Add(XmlValue.CreateNullable("UInt32", MyInt32[0])).Add(XmlValue.CreateNullable("UInt32", MyInt32[1])); var xmlUInt64 = new XmlArray("ArrayOfUInt64").Add(XmlValue.CreateNullable("UInt64", MyInt32[0])).Add(XmlValue.CreateNullable("UInt64", MyInt64[1])); var xmlMyDec = new XmlArray("ArrayOfDecimal").Add(XmlValue.CreateNullable("Decimal", MyDec[0])).Add(XmlValue.CreateNullable("Decimal", MyDec[1])); var xmlMyDouble = new XmlArray("ArrayOfDouble").Add(XmlValue.CreateNullable("Double", MyDouble[0])).Add(XmlValue.CreateNullable("Double", MyDouble[1])); var xmlMySingle = new XmlArray("ArrayOfSingle").Add(XmlValue.CreateNullable("Single", MySingle[0])).Add(XmlValue.CreateNullable("Single", MySingle[1])); var resultInt16 = service.GetRoot(xmlInt16); var resultInt32 = service.GetRoot(xmlInt32); var resultInt64 = service.GetRoot(xmlInt64); var resultByte = service.GetRoot(xmlByte); var resultSByte = service.GetRoot(xmlSByte); var resultUInt16 = service.GetRoot(xmlUInt16); var resultUInt32 = service.GetRoot(xmlUInt32); var resultUInt64 = service.GetRoot(xmlUInt64); var resultMyDec = service.GetRoot(xmlMyDec); var resultMyDouble = service.GetRoot(xmlMyDouble); var resultMySingle = service.GetRoot(xmlMySingle); Assert.AreEqual("<ArrayOfInt16><Int16>10</Int16><Int16>20</Int16></ArrayOfInt16>", resultInt16); Assert.AreEqual("<ArrayOfInt32><Int32>10</Int32><Int32>20</Int32></ArrayOfInt32>", resultInt32); Assert.AreEqual("<ArrayOfInt64><Int64>10</Int64><Int64>20</Int64></ArrayOfInt64>", resultInt64); Assert.AreEqual("<ArrayOfByte><Byte>201</Byte><Byte>202</Byte></ArrayOfByte>", resultByte); Assert.AreEqual("<ArrayOfSByte><SByte>-102</SByte><SByte>101</SByte></ArrayOfSByte>", resultSByte); Assert.AreEqual("<ArrayOfUInt16><UInt16>10</UInt16><UInt16>20</UInt16></ArrayOfUInt16>", resultUInt16); Assert.AreEqual("<ArrayOfUInt32><UInt32>10</UInt32><UInt32>20</UInt32></ArrayOfUInt32>", resultUInt32); Assert.AreEqual("<ArrayOfUInt64><UInt64>10</UInt64><UInt64>20</UInt64></ArrayOfUInt64>", resultUInt64); Assert.AreEqual("<ArrayOfDecimal><Decimal>10.5</Decimal><Decimal>11.5</Decimal></ArrayOfDecimal>", resultMyDec); Assert.AreEqual("<ArrayOfDouble><Double>10.5</Double><Double>11.5</Double></ArrayOfDouble>", resultMyDouble); Assert.AreEqual("<ArrayOfSingle><Single>10.5</Single><Single>11.5</Single></ArrayOfSingle>", resultMySingle); }
public void TestNumberNullablesNull() { var service = this.GetService(); int? MyInt = null; Int16?MyInt16 = null; Int32?MyInt32 = null; Int64?MyInt64 = null; Byte? MyByte = null; SByte?MySByte = null; UInt16?MyUInt16 = null; UInt32?MyUInt32 = null; UInt64?MyUInt64 = null; Decimal?MyDec = null; Double? MyDouble = null; Single? MySingle = null; var xmlInt = XmlValue.CreateNullable <int?>("Int32", MyInt); var xmlInt16 = XmlValue.CreateNullable <Int16?>("Int16", MyInt16); var xmlInt32 = XmlValue.CreateNullable <Int32?>("Int32", MyInt32); var xmlInt64 = XmlValue.CreateNullable <Int64?>("Int64", MyInt64); var xmlByte = XmlValue.CreateNullable <Byte?>("Byte", MyByte); var xmlSByte = XmlValue.CreateNullable <SByte?>("SByte", MySByte); var xmlUInt16 = XmlValue.CreateNullable <UInt16?>("UInt16", MyUInt16); var xmlUInt32 = XmlValue.CreateNullable <UInt32?>("UInt32", MyUInt32); var xmlUInt64 = XmlValue.CreateNullable <UInt64?>("UInt64", MyUInt64); var xmlMyDec = XmlValue.CreateNullable <Decimal?>("Decimal", MyDec); var xmlMyDouble = XmlValue.CreateNullable <Double?>("Double", MyDouble); var xmlMySingle = XmlValue.CreateNullable <Single?>("Single", MySingle); var resultInt = service.GetRoot(xmlInt); var resultInt16 = service.GetRoot(xmlInt16); var resultInt32 = service.GetRoot(xmlInt32); var resultInt64 = service.GetRoot(xmlInt64); var resultByte = service.GetRoot(xmlByte); var resultSByte = service.GetRoot(xmlSByte); var resultUInt16 = service.GetRoot(xmlUInt16); var resultUInt32 = service.GetRoot(xmlUInt32); var resultUInt64 = service.GetRoot(xmlUInt64); var resultMyDec = service.GetRoot(xmlMyDec); var resultMyDouble = service.GetRoot(xmlMyDouble); var resultMySingle = service.GetRoot(xmlMySingle); Assert.AreEqual("<Int32 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\" />", resultInt); Assert.AreEqual("<Int16 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\" />", resultInt16); Assert.AreEqual("<Int32 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\" />", resultInt32); Assert.AreEqual("<Int64 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\" />", resultInt64); Assert.AreEqual("<Byte xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\" />", resultByte); Assert.AreEqual("<SByte xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\" />", resultSByte); Assert.AreEqual("<UInt16 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\" />", resultUInt16); Assert.AreEqual("<UInt32 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\" />", resultUInt32); Assert.AreEqual("<UInt64 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\" />", resultUInt64); Assert.AreEqual("<Decimal xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\" />", resultMyDec); Assert.AreEqual("<Double xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\" />", resultMyDouble); Assert.AreEqual("<Single xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\" />", resultMySingle); }
public void TestNumberNullables() { var service = this.GetService(); int? MyInt = 10; Int16?MyInt16 = 10; Int32?MyInt32 = 10; Int64?MyInt64 = 10; Byte? MyByte = 201; SByte?MySByte = -102; UInt16?MyUInt16 = 10; UInt32?MyUInt32 = 10; UInt64?MyUInt64 = 10; Decimal?MyDec = 10.5M; Double? MyDouble = 10.5; Single? MySingle = 10.5F; var xmlInt = XmlValue.CreateNullable <int?>("Int32", MyInt); var xmlInt16 = XmlValue.CreateNullable <Int16?>("Int16", MyInt16); var xmlInt32 = XmlValue.CreateNullable <Int32?>("Int32", MyInt32); var xmlInt64 = XmlValue.CreateNullable <Int64?>("Int64", MyInt64); var xmlByte = XmlValue.CreateNullable <Byte?>("Byte", MyByte); var xmlSByte = XmlValue.CreateNullable <SByte?>("SByte", MySByte); var xmlUInt16 = XmlValue.CreateNullable <UInt16?>("UInt16", MyUInt16); var xmlUInt32 = XmlValue.CreateNullable <UInt32?>("UInt32", MyUInt32); var xmlUInt64 = XmlValue.CreateNullable <UInt64?>("UInt64", MyUInt64); var xmlMyDec = XmlValue.CreateNullable <Decimal?>("Decimal", MyDec); var xmlMyDouble = XmlValue.CreateNullable <Double?>("Double", MyDouble); var xmlMySingle = XmlValue.CreateNullable <Single?>("Single", MySingle); var resultInt = service.GetRoot(xmlInt); var resultInt16 = service.GetRoot(xmlInt16); var resultInt32 = service.GetRoot(xmlInt32); var resultInt64 = service.GetRoot(xmlInt64); var resultByte = service.GetRoot(xmlByte); var resultSByte = service.GetRoot(xmlSByte); var resultUInt16 = service.GetRoot(xmlUInt16); var resultUInt32 = service.GetRoot(xmlUInt32); var resultUInt64 = service.GetRoot(xmlUInt64); var resultMyDec = service.GetRoot(xmlMyDec); var resultMyDouble = service.GetRoot(xmlMyDouble); var resultMySingle = service.GetRoot(xmlMySingle); Assert.AreEqual("<Int32>10</Int32>", resultInt); Assert.AreEqual("<Int16>10</Int16>", resultInt16); Assert.AreEqual("<Int32>10</Int32>", resultInt32); Assert.AreEqual("<Int64>10</Int64>", resultInt64); Assert.AreEqual("<Byte>201</Byte>", resultByte); Assert.AreEqual("<SByte>-102</SByte>", resultSByte); Assert.AreEqual("<UInt16>10</UInt16>", resultUInt16); Assert.AreEqual("<UInt32>10</UInt32>", resultUInt32); Assert.AreEqual("<UInt64>10</UInt64>", resultUInt64); Assert.AreEqual("<Decimal>10.5</Decimal>", resultMyDec); Assert.AreEqual("<Double>10.5</Double>", resultMyDouble); Assert.AreEqual("<Single>10.5</Single>", resultMySingle); }