SoapReflectionImporterTests.cs 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955
  1. //
  2. // System.Xml.Serialization.SoapReflectionImporterTests
  3. //
  4. // Author:
  5. // Gert Driesen ([email protected])
  6. //
  7. // (C) 2005 Novell
  8. //
  9. using System;
  10. using System.Collections;
  11. using DefaultValueAttribute = System.ComponentModel.DefaultValueAttribute;
  12. using System.Xml;
  13. using System.Xml.Schema;
  14. using System.Xml.Serialization;
  15. using NUnit.Framework;
  16. using MonoTests.System.Xml.TestClasses;
  17. namespace MonoTests.System.XmlSerialization
  18. {
  19. [TestFixture]
  20. public class SoapReflectionImporterTests
  21. {
  22. private const string SomeNamespace = "some:urn";
  23. private const string AnotherNamespace = "another:urn";
  24. private const string XmlSchemaNamespace = "http://www.w3.org/2001/XMLSchema";
  25. private const string WsdlTypesNamespace = "http://microsoft.com/wsdl/types/";
  26. // these Map methods re-create the SoapReflectionImporter at every call.
  27. private XmlTypeMapping Map (Type t)
  28. {
  29. SoapReflectionImporter ri = new SoapReflectionImporter ();
  30. XmlTypeMapping tm = ri.ImportTypeMapping (t);
  31. return tm;
  32. }
  33. private XmlTypeMapping Map (Type t, string ns)
  34. {
  35. SoapReflectionImporter ri = new SoapReflectionImporter (ns);
  36. XmlTypeMapping tm = ri.ImportTypeMapping (t);
  37. return tm;
  38. }
  39. private XmlTypeMapping Map (Type t, SoapAttributeOverrides overrides)
  40. {
  41. SoapReflectionImporter ri = new SoapReflectionImporter(overrides);
  42. XmlTypeMapping tm = ri.ImportTypeMapping(t);
  43. return tm;
  44. }
  45. private XmlMembersMapping MembersMap (Type t, SoapAttributeOverrides overrides,
  46. XmlReflectionMember [] members, bool inContainer, bool writeAccessors)
  47. {
  48. SoapReflectionImporter ri = new SoapReflectionImporter (overrides);
  49. XmlMembersMapping mm = ri.ImportMembersMapping (null, null, members,
  50. inContainer, writeAccessors);
  51. return mm;
  52. }
  53. [Test]
  54. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  55. public void TestIntTypeMapping ()
  56. {
  57. XmlTypeMapping tm = Map (typeof (int));
  58. Assert.AreEqual ("int", tm.ElementName, "#1");
  59. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
  60. Assert.AreEqual ("Int32", tm.TypeName, "#3");
  61. Assert.AreEqual ("System.Int32", tm.TypeFullName, "#4");
  62. }
  63. [Test]
  64. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  65. public void TestIntTypeMapping_DefaultNamespace ()
  66. {
  67. XmlTypeMapping tm = Map (typeof (int), SomeNamespace);
  68. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
  69. tm = Map (typeof (int[]), SomeNamespace);
  70. Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
  71. tm = Map (typeof (int[][]), SomeNamespace);
  72. Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
  73. }
  74. [Test]
  75. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  76. public void TestIntTypeMapping_Array ()
  77. {
  78. XmlTypeMapping tm = Map (typeof (int[]));
  79. Assert.AreEqual ("ArrayOfInt", tm.ElementName, "#A1");
  80. Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
  81. #if NET_2_0
  82. Assert.AreEqual ("ArrayOfInt32", tm.TypeName, "#A3");
  83. #else
  84. Assert.AreEqual ("Int32[]", tm.TypeName, "#A3");
  85. #endif
  86. Assert.AreEqual ("System.Int32[]", tm.TypeFullName, "#A4");
  87. tm = Map (typeof (int[][]));
  88. Assert.AreEqual ("ArrayOfArrayOfInt", tm.ElementName, "#B1");
  89. Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
  90. #if NET_2_0
  91. Assert.AreEqual ("ArrayOfArrayOfInt32", tm.TypeName, "#B3");
  92. #else
  93. Assert.AreEqual ("Int32[][]", tm.TypeName, "#B3");
  94. #endif
  95. Assert.AreEqual ("System.Int32[][]", tm.TypeFullName, "#B4");
  96. }
  97. [Test]
  98. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  99. public void TestStringTypeMapping ()
  100. {
  101. XmlTypeMapping tm = Map (typeof (string));
  102. Assert.AreEqual ("string", tm.ElementName, "#1");
  103. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
  104. Assert.AreEqual ("String", tm.TypeName, "#3");
  105. Assert.AreEqual ("System.String", tm.TypeFullName, "#4");
  106. }
  107. [Test]
  108. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  109. public void TestStringTypeMapping_DefaultNamespace ()
  110. {
  111. XmlTypeMapping tm = Map (typeof (string), SomeNamespace);
  112. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
  113. tm = Map (typeof (string[]), SomeNamespace);
  114. Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
  115. tm = Map (typeof (string[][]), SomeNamespace);
  116. Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
  117. }
  118. [Test]
  119. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  120. public void TestStringTypeMapping_Array ()
  121. {
  122. XmlTypeMapping tm = Map (typeof (string[]));
  123. Assert.AreEqual ("ArrayOfString", tm.ElementName, "#A1");
  124. Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
  125. #if NET_2_0
  126. Assert.AreEqual ("ArrayOfString", tm.TypeName, "#A3");
  127. #else
  128. Assert.AreEqual ("String[]", tm.TypeName, "#A3");
  129. #endif
  130. Assert.AreEqual ("System.String[]", tm.TypeFullName, "#A4");
  131. tm = Map (typeof (string[][]));
  132. Assert.AreEqual ("ArrayOfArrayOfString", tm.ElementName, "#B1");
  133. Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
  134. #if NET_2_0
  135. Assert.AreEqual ("ArrayOfArrayOfString", tm.TypeName, "#B3");
  136. #else
  137. Assert.AreEqual ("String[][]", tm.TypeName, "#B3");
  138. #endif
  139. Assert.AreEqual ("System.String[][]", tm.TypeFullName, "#B4");
  140. }
  141. [Test]
  142. public void TestObjectTypeMapping ()
  143. {
  144. XmlTypeMapping tm = Map (typeof (object));
  145. Assert.AreEqual ("anyType", tm.ElementName, "#1");
  146. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
  147. Assert.AreEqual ("Object", tm.TypeName, "#3");
  148. Assert.AreEqual ("System.Object", tm.TypeFullName, "#4");
  149. }
  150. [Test]
  151. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  152. public void TestObjectTypeMapping_DefaultNamespace ()
  153. {
  154. XmlTypeMapping tm = Map (typeof (object), SomeNamespace);
  155. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
  156. tm = Map (typeof (object[]), SomeNamespace);
  157. Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
  158. tm = Map (typeof (object[][]), SomeNamespace);
  159. Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
  160. }
  161. [Test]
  162. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  163. public void TestObjectTypeMapping_Array ()
  164. {
  165. XmlTypeMapping tm = Map (typeof (object[]));
  166. Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#A1");
  167. Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
  168. #if NET_2_0
  169. Assert.AreEqual ("ArrayOfObject", tm.TypeName, "#A3");
  170. #else
  171. Assert.AreEqual ("Object[]", tm.TypeName, "#A3");
  172. #endif
  173. Assert.AreEqual ("System.Object[]", tm.TypeFullName, "#A4");
  174. tm = Map (typeof (object[][]));
  175. Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#B1");
  176. Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
  177. #if NET_2_0
  178. Assert.AreEqual ("ArrayOfArrayOfObject", tm.TypeName, "#B3");
  179. #else
  180. Assert.AreEqual ("Object[][]", tm.TypeName, "#B3");
  181. #endif
  182. Assert.AreEqual ("System.Object[][]", tm.TypeFullName, "#B4");
  183. }
  184. [Test]
  185. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  186. public void TestByteTypeMapping ()
  187. {
  188. XmlTypeMapping tm = Map (typeof (byte));
  189. Assert.AreEqual ("unsignedByte", tm.ElementName, "#1");
  190. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
  191. Assert.AreEqual ("Byte", tm.TypeName, "#3");
  192. Assert.AreEqual ("System.Byte", tm.TypeFullName, "#4");
  193. }
  194. [Test]
  195. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  196. public void TestByteTypeMapping_DefaultNamespace ()
  197. {
  198. XmlTypeMapping tm = Map (typeof (byte), SomeNamespace);
  199. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
  200. tm = Map (typeof (byte[]), SomeNamespace);
  201. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
  202. tm = Map (typeof (byte[][]), SomeNamespace);
  203. Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
  204. }
  205. [Test]
  206. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  207. public void TestByteTypeMapping_Array ()
  208. {
  209. XmlTypeMapping tm = Map (typeof (byte[]));
  210. Assert.AreEqual ("base64Binary", tm.ElementName, "#A1");
  211. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#A2");
  212. Assert.AreEqual ("Byte[]", tm.TypeName, "#A3");
  213. Assert.AreEqual ("System.Byte[]", tm.TypeFullName, "#A4");
  214. tm = Map (typeof (byte[][]));
  215. Assert.AreEqual ("ArrayOfBase64Binary", tm.ElementName, "#B1");
  216. Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
  217. #if NET_2_0
  218. Assert.AreEqual ("ArrayOfArrayOfByte", tm.TypeName, "#B3");
  219. #else
  220. Assert.AreEqual ("Byte[][]", tm.TypeName, "#B3");
  221. #endif
  222. Assert.AreEqual ("System.Byte[][]", tm.TypeFullName, "#B4");
  223. }
  224. [Test]
  225. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  226. public void TestBoolTypeMapping ()
  227. {
  228. XmlTypeMapping tm = Map (typeof (bool));
  229. Assert.AreEqual ("boolean", tm.ElementName, "#1");
  230. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
  231. Assert.AreEqual ("Boolean", tm.TypeName, "#3");
  232. Assert.AreEqual ("System.Boolean", tm.TypeFullName, "#4");
  233. }
  234. [Test]
  235. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  236. public void TestBoolTypeMapping_DefaultNamespace ()
  237. {
  238. XmlTypeMapping tm = Map (typeof (bool), "http://somenamespace");
  239. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
  240. tm = Map (typeof (bool[]), SomeNamespace);
  241. Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
  242. tm = Map (typeof (bool[][]), SomeNamespace);
  243. Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
  244. }
  245. [Test]
  246. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  247. public void TestShortTypeMapping ()
  248. {
  249. XmlTypeMapping tm = Map (typeof (short));
  250. Assert.AreEqual ("short", tm.ElementName, "#1");
  251. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
  252. Assert.AreEqual ("Int16", tm.TypeName, "#3");
  253. Assert.AreEqual ("System.Int16", tm.TypeFullName, "#4");
  254. }
  255. [Test]
  256. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  257. public void TestShortTypeMapping_DefaultNamespace ()
  258. {
  259. XmlTypeMapping tm = Map (typeof (short), SomeNamespace);
  260. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
  261. tm = Map (typeof (short[]), SomeNamespace);
  262. Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
  263. tm = Map (typeof (short[][]), SomeNamespace);
  264. Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
  265. }
  266. [Test]
  267. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  268. public void TestUnsignedShortTypeMapping ()
  269. {
  270. XmlTypeMapping tm = Map (typeof (ushort));
  271. Assert.AreEqual ("unsignedShort", tm.ElementName, "#1");
  272. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
  273. Assert.AreEqual ("UInt16", tm.TypeName, "#3");
  274. Assert.AreEqual ("System.UInt16", tm.TypeFullName, "#4");
  275. }
  276. [Test]
  277. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  278. public void TestUnsignedShortTypeMapping_DefaultNamespace ()
  279. {
  280. XmlTypeMapping tm = Map (typeof (ushort), SomeNamespace);
  281. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
  282. tm = Map (typeof (ushort[]), SomeNamespace);
  283. Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
  284. tm = Map (typeof (ushort[][]), SomeNamespace);
  285. Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
  286. }
  287. [Test]
  288. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  289. public void TestUIntTypeMapping ()
  290. {
  291. XmlTypeMapping tm = Map (typeof (uint));
  292. Assert.AreEqual ("unsignedInt", tm.ElementName, "#1");
  293. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
  294. Assert.AreEqual ("UInt32", tm.TypeName, "#3");
  295. Assert.AreEqual ("System.UInt32", tm.TypeFullName, "#4");
  296. }
  297. [Test]
  298. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  299. public void TestUIntTypeMapping_DefaultNamespace ()
  300. {
  301. XmlTypeMapping tm = Map (typeof (uint), SomeNamespace);
  302. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
  303. tm = Map (typeof (uint[]), SomeNamespace);
  304. Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
  305. tm = Map (typeof (uint[][]), SomeNamespace);
  306. Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
  307. }
  308. [Test]
  309. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  310. public void TestLongTypeMapping ()
  311. {
  312. XmlTypeMapping tm = Map (typeof (long));
  313. Assert.AreEqual ("long", tm.ElementName, "#1");
  314. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
  315. Assert.AreEqual ("Int64", tm.TypeName, "#3");
  316. Assert.AreEqual ("System.Int64", tm.TypeFullName, "#4");
  317. }
  318. [Test]
  319. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  320. public void TestLongTypeMapping_DefaultNamespace ()
  321. {
  322. XmlTypeMapping tm = Map (typeof (long), SomeNamespace);
  323. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
  324. tm = Map (typeof (long[]), SomeNamespace);
  325. Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
  326. tm = Map (typeof (long[][]), SomeNamespace);
  327. Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
  328. }
  329. [Test]
  330. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  331. public void TestULongTypeMapping ()
  332. {
  333. XmlTypeMapping tm = Map (typeof (ulong));
  334. Assert.AreEqual ("unsignedLong", tm.ElementName, "#1");
  335. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
  336. Assert.AreEqual ("UInt64", tm.TypeName, "#3");
  337. Assert.AreEqual ("System.UInt64", tm.TypeFullName, "#4");
  338. }
  339. [Test]
  340. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  341. public void TestULongTypeMapping_DefaultNamespace ()
  342. {
  343. XmlTypeMapping tm = Map (typeof (ulong), SomeNamespace);
  344. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
  345. tm = Map (typeof (ulong[]), SomeNamespace);
  346. Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
  347. tm = Map (typeof (ulong[][]), SomeNamespace);
  348. Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
  349. }
  350. [Test]
  351. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  352. public void TestFloatTypeMapping ()
  353. {
  354. XmlTypeMapping tm = Map (typeof (float));
  355. Assert.AreEqual ("float", tm.ElementName, "#1");
  356. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
  357. Assert.AreEqual ("Single", tm.TypeName, "#3");
  358. Assert.AreEqual ("System.Single", tm.TypeFullName, "#4");
  359. }
  360. [Test]
  361. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  362. public void TestFloatTypeMapping_DefaultNamespace ()
  363. {
  364. XmlTypeMapping tm = Map (typeof (float), SomeNamespace);
  365. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
  366. tm = Map (typeof (float[]), SomeNamespace);
  367. Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
  368. tm = Map (typeof (float[][]), SomeNamespace);
  369. Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
  370. }
  371. [Test]
  372. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  373. public void TestDoubleTypeMapping ()
  374. {
  375. XmlTypeMapping tm = Map (typeof (double));
  376. Assert.AreEqual ("double", tm.ElementName, "#1");
  377. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
  378. Assert.AreEqual ("Double", tm.TypeName, "#3");
  379. Assert.AreEqual ("System.Double", tm.TypeFullName, "#4");
  380. }
  381. [Test]
  382. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  383. public void TestDoubleTypeMapping_DefaultNamespace ()
  384. {
  385. XmlTypeMapping tm = Map (typeof (double), SomeNamespace);
  386. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
  387. tm = Map (typeof (double[]), SomeNamespace);
  388. Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
  389. tm = Map (typeof (double[][]), SomeNamespace);
  390. Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
  391. }
  392. [Test]
  393. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  394. public void TestDateTimeTypeMapping ()
  395. {
  396. XmlTypeMapping tm = Map (typeof (DateTime));
  397. Assert.AreEqual ("dateTime", tm.ElementName, "#1");
  398. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
  399. Assert.AreEqual ("DateTime", tm.TypeName, "#3");
  400. Assert.AreEqual ("System.DateTime", tm.TypeFullName, "#4");
  401. }
  402. [Test]
  403. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  404. public void TestDateTimeTypeMapping_DefaultNamespace ()
  405. {
  406. XmlTypeMapping tm = Map (typeof (DateTime), SomeNamespace);
  407. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
  408. tm = Map (typeof (DateTime[]), SomeNamespace);
  409. Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
  410. tm = Map (typeof (DateTime[][]), SomeNamespace);
  411. Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
  412. }
  413. [Test]
  414. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  415. public void TestDateTimeTypeMapping_Array ()
  416. {
  417. XmlTypeMapping tm = Map (typeof (DateTime[]));
  418. Assert.AreEqual ("ArrayOfDateTime", tm.ElementName, "#A1");
  419. Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
  420. #if NET_2_0
  421. Assert.AreEqual ("ArrayOfDateTime", tm.TypeName, "#A3");
  422. #else
  423. Assert.AreEqual ("DateTime[]", tm.TypeName, "#A3");
  424. #endif
  425. Assert.AreEqual ("System.DateTime[]", tm.TypeFullName, "#A4");
  426. tm = Map (typeof (DateTime[][]));
  427. Assert.AreEqual ("ArrayOfArrayOfDateTime", tm.ElementName, "#B1");
  428. Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
  429. #if NET_2_0
  430. Assert.AreEqual ("ArrayOfArrayOfDateTime", tm.TypeName, "#B3");
  431. #else
  432. Assert.AreEqual ("DateTime[][]", tm.TypeName, "#B3");
  433. #endif
  434. Assert.AreEqual ("System.DateTime[][]", tm.TypeFullName, "#B4");
  435. }
  436. [Test]
  437. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  438. public void TestGuidTypeMapping ()
  439. {
  440. XmlTypeMapping tm = Map (typeof (Guid));
  441. Assert.AreEqual ("guid", tm.ElementName, "#1");
  442. Assert.AreEqual (WsdlTypesNamespace, tm.Namespace, "#2");
  443. Assert.AreEqual ("Guid", tm.TypeName, "#3");
  444. Assert.AreEqual ("System.Guid", tm.TypeFullName, "#4");
  445. }
  446. [Test]
  447. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  448. public void TestGuidTypeMapping_DefaultNamespace ()
  449. {
  450. XmlTypeMapping tm = Map (typeof (Guid), SomeNamespace);
  451. Assert.AreEqual (WsdlTypesNamespace, tm.Namespace, "#1");
  452. tm = Map (typeof (Guid[]), SomeNamespace);
  453. Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
  454. tm = Map (typeof (Guid[][]), SomeNamespace);
  455. Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
  456. }
  457. [Test]
  458. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  459. public void TestGuidTypeMapping_Array ()
  460. {
  461. XmlTypeMapping tm = Map (typeof (Guid[]));
  462. Assert.AreEqual ("ArrayOfGuid", tm.ElementName, "#A1");
  463. Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
  464. #if NET_2_0
  465. Assert.AreEqual ("ArrayOfGuid", tm.TypeName, "#A3");
  466. #else
  467. Assert.AreEqual ("Guid[]", tm.TypeName, "#A3");
  468. #endif
  469. Assert.AreEqual ("System.Guid[]", tm.TypeFullName, "#A4");
  470. tm = Map (typeof (Guid[][]));
  471. Assert.AreEqual ("ArrayOfArrayOfGuid", tm.ElementName, "#B1");
  472. Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
  473. #if NET_2_0
  474. Assert.AreEqual ("ArrayOfArrayOfGuid", tm.TypeName, "#B3");
  475. #else
  476. Assert.AreEqual ("Guid[][]", tm.TypeName, "#B3");
  477. #endif
  478. Assert.AreEqual ("System.Guid[][]", tm.TypeFullName, "#B4");
  479. }
  480. [Test]
  481. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  482. public void TestDecimalTypeMapping ()
  483. {
  484. XmlTypeMapping tm = Map (typeof (decimal));
  485. Assert.AreEqual ("decimal", tm.ElementName, "#1");
  486. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
  487. Assert.AreEqual ("Decimal", tm.TypeName, "#3");
  488. Assert.AreEqual ("System.Decimal", tm.TypeFullName, "#4");
  489. }
  490. [Test]
  491. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  492. public void TestDecimalTypeMapping_DefaultNamespace ()
  493. {
  494. XmlTypeMapping tm = Map (typeof (decimal), SomeNamespace);
  495. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
  496. tm = Map (typeof (decimal[]), SomeNamespace);
  497. Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
  498. tm = Map (typeof (decimal[][]), SomeNamespace);
  499. Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
  500. }
  501. [Test]
  502. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  503. public void TestXmlQualifiedNameTypeMapping ()
  504. {
  505. XmlTypeMapping tm = Map (typeof (XmlQualifiedName));
  506. Assert.AreEqual ("QName", tm.ElementName, "#1");
  507. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
  508. Assert.AreEqual ("XmlQualifiedName", tm.TypeName, "#3");
  509. Assert.AreEqual ("System.Xml.XmlQualifiedName", tm.TypeFullName, "#4");
  510. }
  511. [Test]
  512. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  513. public void TestXmlQualifiedNameTypeMapping_DefaultNamespace ()
  514. {
  515. XmlTypeMapping tm = Map (typeof (XmlQualifiedName), SomeNamespace);
  516. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
  517. tm = Map (typeof (XmlQualifiedName[]), SomeNamespace);
  518. Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
  519. tm = Map (typeof (XmlQualifiedName[][]), SomeNamespace);
  520. Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
  521. }
  522. [Test]
  523. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  524. public void TestXmlQualifiedNameTypeMapping_Array ()
  525. {
  526. XmlTypeMapping tm = Map (typeof (XmlQualifiedName[]));
  527. Assert.AreEqual ("ArrayOfQName", tm.ElementName, "#A1");
  528. Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
  529. #if NET_2_0
  530. Assert.AreEqual ("ArrayOfXmlQualifiedName", tm.TypeName, "#A3");
  531. #else
  532. Assert.AreEqual ("XmlQualifiedName[]", tm.TypeName, "#A3");
  533. #endif
  534. Assert.AreEqual ("System.Xml.XmlQualifiedName[]", tm.TypeFullName, "#A4");
  535. tm = Map (typeof (XmlQualifiedName[][]));
  536. Assert.AreEqual ("ArrayOfArrayOfQName", tm.ElementName, "#B1");
  537. Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
  538. #if NET_2_0
  539. Assert.AreEqual ("ArrayOfArrayOfXmlQualifiedName", tm.TypeName, "#B3");
  540. #else
  541. Assert.AreEqual ("XmlQualifiedName[][]", tm.TypeName, "#B3");
  542. #endif
  543. Assert.AreEqual ("System.Xml.XmlQualifiedName[][]", tm.TypeFullName, "#B4");
  544. }
  545. [Test]
  546. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  547. public void TestSByteTypeMapping ()
  548. {
  549. XmlTypeMapping tm = Map (typeof (sbyte));
  550. Assert.AreEqual ("byte", tm.ElementName, "#1");
  551. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#2");
  552. Assert.AreEqual ("SByte", tm.TypeName, "#3");
  553. Assert.AreEqual ("System.SByte", tm.TypeFullName, "#4");
  554. }
  555. [Test]
  556. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  557. public void TestSByteTypeMapping_DefaultNamespace ()
  558. {
  559. XmlTypeMapping tm = Map (typeof (sbyte), SomeNamespace);
  560. Assert.AreEqual (XmlSchemaNamespace, tm.Namespace, "#1");
  561. tm = Map (typeof (sbyte[]), SomeNamespace);
  562. Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
  563. tm = Map (typeof (sbyte[][]), SomeNamespace);
  564. Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
  565. }
  566. [Test]
  567. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  568. public void TestSByteTypeMapping_Array ()
  569. {
  570. XmlTypeMapping tm = Map (typeof (sbyte[]));
  571. Assert.AreEqual ("ArrayOfByte", tm.ElementName, "#A1");
  572. Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
  573. #if NET_2_0
  574. Assert.AreEqual ("ArrayOfSByte", tm.TypeName, "#A3");
  575. #else
  576. Assert.AreEqual ("SByte[]", tm.TypeName, "#A3");
  577. #endif
  578. Assert.AreEqual ("System.SByte[]", tm.TypeFullName, "#A4");
  579. tm = Map (typeof (sbyte[][]));
  580. Assert.AreEqual ("ArrayOfArrayOfByte", tm.ElementName, "#B1");
  581. Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
  582. #if NET_2_0
  583. Assert.AreEqual ("ArrayOfArrayOfSByte", tm.TypeName, "#B3");
  584. #else
  585. Assert.AreEqual ("SByte[][]", tm.TypeName, "#B3");
  586. #endif
  587. Assert.AreEqual ("System.SByte[][]", tm.TypeFullName, "#B4");
  588. }
  589. [Test]
  590. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  591. public void TestCharTypeMapping()
  592. {
  593. XmlTypeMapping tm = Map (typeof (char));
  594. Assert.AreEqual ("char", tm.ElementName, "#1");
  595. Assert.AreEqual (WsdlTypesNamespace, tm.Namespace, "#2");
  596. Assert.AreEqual ("Char", tm.TypeName, "#3");
  597. Assert.AreEqual ("System.Char", tm.TypeFullName, "#4");
  598. }
  599. [Test]
  600. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  601. public void TestCharTypeMapping_DefaultNamespace ()
  602. {
  603. XmlTypeMapping tm = Map (typeof (char), SomeNamespace);
  604. Assert.AreEqual (WsdlTypesNamespace, tm.Namespace, "#1");
  605. tm = Map (typeof (char[]), SomeNamespace);
  606. Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
  607. tm = Map (typeof (char[][]), SomeNamespace);
  608. Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
  609. }
  610. [Test]
  611. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  612. public void TestCharTypeMapping_Array ()
  613. {
  614. XmlTypeMapping tm = Map (typeof (char[]));
  615. Assert.AreEqual ("ArrayOfChar", tm.ElementName, "#A1");
  616. Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
  617. #if NET_2_0
  618. Assert.AreEqual ("ArrayOfChar", tm.TypeName, "#A3");
  619. #else
  620. Assert.AreEqual ("Char[]", tm.TypeName, "#A3");
  621. #endif
  622. Assert.AreEqual ("System.Char[]", tm.TypeFullName, "#A4");
  623. tm = Map (typeof (char[][]));
  624. Assert.AreEqual ("ArrayOfArrayOfChar", tm.ElementName, "#B1");
  625. Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
  626. #if NET_2_0
  627. Assert.AreEqual ("ArrayOfArrayOfChar", tm.TypeName, "#B3");
  628. #else
  629. Assert.AreEqual ("Char[][]", tm.TypeName, "#B3");
  630. #endif
  631. Assert.AreEqual ("System.Char[][]", tm.TypeFullName, "#B4");
  632. }
  633. [Test]
  634. public void TestXmlNodeTypeMapping ()
  635. {
  636. try {
  637. Map (typeof (XmlNode));
  638. Assert.Fail ("#1");
  639. } catch (NotSupportedException) {
  640. // The type System.Xml.XmlNode may not be serialized with SOAP-encoded messages.
  641. }
  642. try {
  643. Map (typeof (XmlNode[]));
  644. Assert.Fail ("#2");
  645. } catch (NotSupportedException) {
  646. // The type System.Xml.XmlNode may not be serialized with SOAP-encoded messages.
  647. }
  648. try {
  649. Map (typeof (XmlNode[][]));
  650. Assert.Fail ("#3");
  651. } catch (NotSupportedException) {
  652. // The type System.Xml.XmlNode may not be serialized with SOAP-encoded messages.
  653. }
  654. }
  655. [Test]
  656. public void TestXmlNodeTypeMapping_DefaultNamespace ()
  657. {
  658. try {
  659. Map (typeof (XmlNode), SomeNamespace);
  660. Assert.Fail ("#1");
  661. } catch (NotSupportedException) {
  662. // The type System.Xml.XmlNode may not be serialized with SOAP-encoded messages.
  663. }
  664. try {
  665. Map (typeof (XmlNode[]), SomeNamespace);
  666. Assert.Fail ("#2");
  667. } catch (NotSupportedException) {
  668. // The type System.Xml.XmlNode may not be serialized with SOAP-encoded messages.
  669. }
  670. try {
  671. Map (typeof (XmlNode[][]), SomeNamespace);
  672. Assert.Fail ("#3");
  673. } catch (NotSupportedException) {
  674. // The type System.Xml.XmlNode may not be serialized with SOAP-encoded messages.
  675. }
  676. }
  677. [Test]
  678. public void TestXmlElementTypeMapping ()
  679. {
  680. try {
  681. Map (typeof (XmlElement));
  682. Assert.Fail ("#1");
  683. } catch (NotSupportedException) {
  684. // The type System.Xml.XmlElement may not be serialized with SOAP-encoded messages.
  685. }
  686. try {
  687. Map (typeof (XmlElement[]));
  688. Assert.Fail ("#2");
  689. } catch (NotSupportedException) {
  690. // The type System.Xml.XmlElement may not be serialized with SOAP-encoded messages.
  691. }
  692. try {
  693. Map (typeof (XmlElement[][]));
  694. Assert.Fail ("#3");
  695. } catch (NotSupportedException) {
  696. // The type System.Xml.XmlElement may not be serialized with SOAP-encoded messages.
  697. }
  698. }
  699. [Test]
  700. public void TestXmlElementTypeMapping_DefaultNamespace ()
  701. {
  702. try {
  703. Map (typeof (XmlElement), SomeNamespace);
  704. Assert.Fail ("#1");
  705. } catch (NotSupportedException) {
  706. // The type System.Xml.XmlElement may not be serialized with SOAP-encoded messages.
  707. }
  708. try {
  709. Map (typeof (XmlElement[]), SomeNamespace);
  710. Assert.Fail ("#2");
  711. } catch (NotSupportedException) {
  712. // The type System.Xml.XmlElement may not be serialized with SOAP-encoded messages.
  713. }
  714. try {
  715. Map (typeof (XmlElement[][]), SomeNamespace);
  716. Assert.Fail ("#3");
  717. } catch (NotSupportedException) {
  718. // The type System.Xml.XmlElement may not be serialized with SOAP-encoded messages.
  719. }
  720. }
  721. [Test]
  722. public void TestXmlNotationTypeMapping ()
  723. {
  724. try {
  725. Map (typeof (XmlNotation));
  726. Assert.Fail ("#1");
  727. } catch (NotSupportedException) {
  728. // The type System.Xml.XmlNotation may not be serialized with SOAP-encoded messages.
  729. }
  730. try {
  731. Map (typeof (XmlNotation[]));
  732. Assert.Fail ("#2");
  733. } catch (NotSupportedException) {
  734. // The type System.Xml.XmlNotation may not be serialized with SOAP-encoded messages.
  735. }
  736. try {
  737. Map (typeof (XmlNotation[][]));
  738. Assert.Fail ("#3");
  739. } catch (NotSupportedException) {
  740. // The type System.Xml.XmlNotation may not be serialized with SOAP-encoded messages.
  741. }
  742. }
  743. [Test]
  744. public void TestXmlNotationTypeMapping_DefaultNamespace ()
  745. {
  746. try {
  747. Map (typeof (XmlNotation), SomeNamespace);
  748. Assert.Fail ("#1");
  749. } catch (NotSupportedException) {
  750. // The type System.Xml.XmlNotation may not be serialized with SOAP-encoded messages.
  751. }
  752. try {
  753. Map (typeof (XmlNotation[]), SomeNamespace);
  754. Assert.Fail ("#2");
  755. } catch (NotSupportedException) {
  756. // The type System.Xml.XmlNotation may not be serialized with SOAP-encoded messages.
  757. }
  758. try {
  759. Map (typeof (XmlNotation[][]), SomeNamespace);
  760. Assert.Fail ("#3");
  761. } catch (NotSupportedException) {
  762. // The type System.Xml.XmlNotation may not be serialized with SOAP-encoded messages.
  763. }
  764. }
  765. [Test]
  766. [ExpectedException (typeof (NotSupportedException))]
  767. public void TestXmlSerializableTypeMapping ()
  768. {
  769. Map (typeof (Employee));
  770. }
  771. [Test]
  772. [Category ("NotWorking")]
  773. [ExpectedException (typeof (NotSupportedException))]
  774. public void TestClassTypeMapping_NestedStruct ()
  775. {
  776. Map (typeof (NestedStruct));
  777. }
  778. [Test]
  779. [ExpectedException (typeof (ArgumentNullException))]
  780. public void TestNullTypeMapping()
  781. {
  782. Map(null);
  783. }
  784. [Test]
  785. [ExpectedException (typeof (ArgumentNullException))]
  786. public void TestNullTypeMapping_DefaultNamespace ()
  787. {
  788. Map (null, SomeNamespace);
  789. }
  790. [Test]
  791. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  792. public void TestStructTypeMapping ()
  793. {
  794. XmlTypeMapping tm = Map (typeof (TimeSpan));
  795. Assert.AreEqual ("TimeSpan", tm.ElementName, "#1");
  796. Assert.AreEqual (string.Empty, tm.Namespace, "#2");
  797. Assert.AreEqual ("TimeSpan", tm.TypeName, "#3");
  798. Assert.AreEqual ("System.TimeSpan", tm.TypeFullName, "#4");
  799. }
  800. [Test]
  801. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  802. public void TestStructTypeMapping_DefaultNamespace ()
  803. {
  804. XmlTypeMapping tm = Map (typeof (TimeSpan), SomeNamespace);
  805. Assert.AreEqual (SomeNamespace, tm.Namespace, "#1");
  806. try {
  807. tm = Map (typeof (TimeSpan[]), SomeNamespace);
  808. Assert.Fail ("#2");
  809. } catch (NotSupportedException) {
  810. }
  811. try {
  812. tm = Map (typeof (TimeSpan[][]), SomeNamespace);
  813. Assert.Fail ("#3");
  814. } catch (NotSupportedException) {
  815. }
  816. }
  817. [Test]
  818. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  819. [ExpectedException (typeof (NotSupportedException))] // Arrays of structs are not supported with encoded SOAP.
  820. public void TestStructTypeMapping_Array ()
  821. {
  822. Map (typeof (TimeSpan[]));
  823. }
  824. [Test]
  825. public void TestEnumTypeMapping ()
  826. {
  827. XmlTypeMapping tm = Map (typeof (AttributeTargets));
  828. Assert.AreEqual ("AttributeTargets", tm.ElementName, "#1");
  829. Assert.AreEqual (string.Empty, tm.Namespace, "#2");
  830. Assert.AreEqual ("AttributeTargets", tm.TypeName, "#3");
  831. Assert.AreEqual ("System.AttributeTargets", tm.TypeFullName, "#4");
  832. }
  833. [Test]
  834. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  835. public void TestEnumTypeMapping_DefaultNamespace ()
  836. {
  837. XmlTypeMapping tm = Map (typeof (AttributeTargets), SomeNamespace);
  838. Assert.AreEqual (SomeNamespace, tm.Namespace, "#1");
  839. tm = Map (typeof (AttributeTargets[]), SomeNamespace);
  840. Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
  841. tm = Map (typeof (AttributeTargets[][]), SomeNamespace);
  842. Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
  843. }
  844. [Test]
  845. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  846. public void TestEnumTypeMapping_Array ()
  847. {
  848. XmlTypeMapping tm = Map (typeof (AttributeTargets[]));
  849. Assert.AreEqual ("ArrayOfAttributeTargets", tm.ElementName, "#A1");
  850. Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
  851. #if NET_2_0
  852. Assert.AreEqual ("ArrayOfAttributeTargets", tm.TypeName, "#A3");
  853. #else
  854. Assert.AreEqual ("AttributeTargets[]", tm.TypeName, "#A3");
  855. #endif
  856. Assert.AreEqual ("System.AttributeTargets[]", tm.TypeFullName, "#A4");
  857. tm = Map (typeof (AttributeTargets[][]));
  858. Assert.AreEqual ("ArrayOfArrayOfAttributeTargets", tm.ElementName, "#B1");
  859. Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
  860. #if NET_2_0
  861. Assert.AreEqual ("ArrayOfArrayOfAttributeTargets", tm.TypeName, "#B3");
  862. #else
  863. Assert.AreEqual ("AttributeTargets[][]", tm.TypeName, "#B3");
  864. #endif
  865. Assert.AreEqual ("System.AttributeTargets[][]", tm.TypeFullName, "#B4");
  866. }
  867. [Test]
  868. public void TestClassTypeMapping()
  869. {
  870. XmlTypeMapping tm = Map (typeof (SimpleClass));
  871. Assert.AreEqual ("SimpleClass", tm.ElementName, "#1");
  872. Assert.AreEqual (string.Empty, tm.Namespace, "#2");
  873. Assert.AreEqual ("SimpleClass", tm.TypeName, "#3");
  874. Assert.AreEqual ("MonoTests.System.Xml.TestClasses.SimpleClass", tm.TypeFullName, "#4");
  875. }
  876. [Test]
  877. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  878. public void TestClassTypeMapping_DefaultNamespace ()
  879. {
  880. XmlTypeMapping tm = Map (typeof (SimpleClass), SomeNamespace);
  881. Assert.AreEqual (SomeNamespace, tm.Namespace, "#1");
  882. tm = Map (typeof (SimpleClass[]), SomeNamespace);
  883. Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
  884. tm = Map (typeof (SimpleClass[][]), SomeNamespace);
  885. Assert.AreEqual (SomeNamespace, tm.Namespace, "#3");
  886. }
  887. [Test]
  888. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  889. public void TestClassTypeMapping_Array ()
  890. {
  891. XmlTypeMapping tm = Map (typeof (SimpleClass[]));
  892. Assert.AreEqual ("ArrayOfSimpleClass", tm.ElementName, "#A1");
  893. Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
  894. #if NET_2_0
  895. Assert.AreEqual ("ArrayOfSimpleClass", tm.TypeName, "#A3");
  896. #else
  897. Assert.AreEqual ("SimpleClass[]", tm.TypeName, "#A3");
  898. #endif
  899. Assert.AreEqual ("MonoTests.System.Xml.TestClasses.SimpleClass[]", tm.TypeFullName, "#A4");
  900. tm = Map (typeof (SimpleClass[][]));
  901. Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.ElementName, "#B1");
  902. Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
  903. #if NET_2_0
  904. Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.TypeName, "#B3");
  905. #else
  906. Assert.AreEqual ("SimpleClass[][]", tm.TypeName, "#B3");
  907. #endif
  908. Assert.AreEqual ("MonoTests.System.Xml.TestClasses.SimpleClass[][]", tm.TypeFullName, "#B4");
  909. }
  910. [Test]
  911. #if ONLY_1_1
  912. [Category ("NotDotNet")] // wrong error message is reported in .NET 1.1
  913. #endif
  914. public void TypeMapping_Attribute_ComplexType ()
  915. {
  916. SoapAttributes attrs = new SoapAttributes (typeof (Field_Encoded).GetMember ("Names")[0]);
  917. attrs.SoapAttribute = new SoapAttributeAttribute (); // SoapAttribute cannot be used to encode complex types
  918. SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
  919. overrides.Add (typeof (Field_Encoded), "Names", attrs);
  920. try {
  921. Map (typeof (Field_Encoded), overrides);
  922. Assert.Fail ("#A1");
  923. } catch (InvalidOperationException ex) {
  924. // Cannot serialize member 'Names' of type System.String[].
  925. // SoapAttribute cannot be used to encode complex types.
  926. Assert.IsNotNull (ex.Message, "#A2");
  927. Assert.IsTrue (ex.Message.IndexOf (typeof (string[]).FullName) != -1, "#A3");
  928. Assert.IsTrue (ex.Message.IndexOf ("SoapAttribute") != -1, "#A4");
  929. Assert.IsNull (ex.InnerException, "#A5");
  930. }
  931. }
  932. [Test]
  933. public void TypeMapping_Field ()
  934. {
  935. XmlTypeMapping tm = Map (typeof (Field));
  936. Assert.AreEqual ("Field", tm.ElementName, "#1");
  937. Assert.AreEqual (string.Empty, tm.Namespace, "#2");
  938. Assert.AreEqual ("Field", tm.TypeName, "#3");
  939. Assert.AreEqual ("MonoTests.System.Xml.TestClasses.Field", tm.TypeFullName, "#4");
  940. }
  941. [Test]
  942. public void TypeMapping_Field_DefaultNamespace ()
  943. {
  944. XmlTypeMapping tm = Map (typeof (Field), SomeNamespace);
  945. Assert.AreEqual ("Field", tm.ElementName, "#1");
  946. Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
  947. Assert.AreEqual ("Field", tm.TypeName, "#3");
  948. Assert.AreEqual ("MonoTests.System.Xml.TestClasses.Field", tm.TypeFullName, "#4");
  949. }
  950. [Test]
  951. public void TypeMapping_Field_Encoded ()
  952. {
  953. XmlTypeMapping tm = Map (typeof (Field_Encoded));
  954. Assert.AreEqual ("field", tm.ElementName, "#1");
  955. Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
  956. Assert.AreEqual ("Field_Encoded", tm.TypeName, "#3");
  957. Assert.AreEqual ("MonoTests.System.Xml.TestClasses.Field_Encoded", tm.TypeFullName, "#4");
  958. }
  959. [Test]
  960. public void TypeMapping_Field_Encoded_DefaultNamespace ()
  961. {
  962. XmlTypeMapping tm = Map (typeof (Field_Encoded), AnotherNamespace);
  963. Assert.AreEqual ("field", tm.ElementName, "#1");
  964. Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
  965. Assert.AreEqual ("Field_Encoded", tm.TypeName, "#3");
  966. Assert.AreEqual ("MonoTests.System.Xml.TestClasses.Field_Encoded", tm.TypeFullName, "#4");
  967. }
  968. [Test]
  969. public void TypeMapping_FlagEnum ()
  970. {
  971. XmlTypeMapping tm = Map (typeof (FlagEnum));
  972. Assert.AreEqual ("FlagEnum", tm.ElementName, "#1");
  973. Assert.AreEqual (string.Empty, tm.Namespace, "#2");
  974. Assert.AreEqual ("FlagEnum", tm.TypeName, "#3");
  975. Assert.AreEqual ("MonoTests.System.Xml.TestClasses.FlagEnum", tm.TypeFullName, "#4");
  976. }
  977. [Test]
  978. public void TypeMapping_FlagEnum_DefaultNamespace ()
  979. {
  980. XmlTypeMapping tm = Map (typeof (FlagEnum), SomeNamespace);
  981. Assert.AreEqual ("FlagEnum", tm.ElementName, "#1");
  982. Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
  983. Assert.AreEqual ("FlagEnum", tm.TypeName, "#3");
  984. Assert.AreEqual ("MonoTests.System.Xml.TestClasses.FlagEnum", tm.TypeFullName, "#4");
  985. }
  986. [Test]
  987. [ExpectedException (typeof (NotSupportedException))]
  988. public void TypeMapping_IDictionary ()
  989. {
  990. // The type MonoTests.System.Xml.TestClasses.DictionaryWithIndexer
  991. // is not supported because it implements IDictionary.
  992. Map (typeof (DictionaryWithIndexer));
  993. }
  994. [Test]
  995. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  996. public void TypeMapping_IEnumerable_SimpleClass ()
  997. {
  998. XmlTypeMapping tm = Map (typeof (SimpleClassEnumerable));
  999. Assert.AreEqual ("ArrayOfSimpleClass", tm.ElementName, "#1");
  1000. Assert.AreEqual (string.Empty, tm.Namespace, "#2");
  1001. Assert.AreEqual ("SimpleClassEnumerable", tm.TypeName, "#3");
  1002. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerable", tm.TypeFullName, "#4");
  1003. tm = Map (typeof (SimpleClassEnumerable[]));
  1004. Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.ElementName, "#A1");
  1005. Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
  1006. #if NET_2_0
  1007. Assert.AreEqual ("ArrayOfSimpleClassEnumerable", tm.TypeName, "#A3");
  1008. #else
  1009. Assert.AreEqual ("SimpleClassEnumerable[]", tm.TypeName, "#A3");
  1010. #endif
  1011. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerable[]", tm.TypeFullName, "#A4");
  1012. tm = Map (typeof (SimpleClassEnumerable[][]));
  1013. Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#B1");
  1014. Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
  1015. #if NET_2_0
  1016. Assert.AreEqual ("ArrayOfArrayOfSimpleClassEnumerable", tm.TypeName, "#B3");
  1017. #else
  1018. Assert.AreEqual ("SimpleClassEnumerable[][]", tm.TypeName, "#B3");
  1019. #endif
  1020. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerable[][]", tm.TypeFullName, "#B4");
  1021. }
  1022. [Test]
  1023. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  1024. public void TypeMapping_IEnumerable_Object ()
  1025. {
  1026. XmlTypeMapping tm = Map (typeof (ObjectEnumerable));
  1027. Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");
  1028. Assert.AreEqual (string.Empty, tm.Namespace, "#2");
  1029. Assert.AreEqual ("ObjectEnumerable", tm.TypeName, "#3");
  1030. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectEnumerable", tm.TypeFullName, "#4");
  1031. tm = Map (typeof (ObjectEnumerable[]));
  1032. Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");
  1033. Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
  1034. #if NET_2_0
  1035. Assert.AreEqual ("ArrayOfObjectEnumerable", tm.TypeName, "#A3");
  1036. #else
  1037. Assert.AreEqual ("ObjectEnumerable[]", tm.TypeName, "#A3");
  1038. #endif
  1039. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectEnumerable[]", tm.TypeFullName, "#A4");
  1040. tm = Map (typeof (ObjectEnumerable[][]));
  1041. Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");
  1042. Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
  1043. #if NET_2_0
  1044. Assert.AreEqual ("ArrayOfArrayOfObjectEnumerable", tm.TypeName, "#B3");
  1045. #else
  1046. Assert.AreEqual ("ObjectEnumerable[][]", tm.TypeName, "#B3");
  1047. #endif
  1048. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectEnumerable[][]", tm.TypeFullName, "#B4");
  1049. }
  1050. [Test]
  1051. [ExpectedException (typeof (InvalidOperationException))]
  1052. public void TypeMapping_IEnumerable_Object_NoMatchingAddMethod ()
  1053. {
  1054. Map (typeof (ObjectEnumerableNoMatchingAddMethod));
  1055. }
  1056. [Test]
  1057. [ExpectedException (typeof (InvalidOperationException))]
  1058. public void TypeMapping_IEnumerable_Object_NoMatchingAddMethod_Array ()
  1059. {
  1060. Map (typeof (ObjectEnumerableNoMatchingAddMethod[]));
  1061. }
  1062. [Test]
  1063. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  1064. public void TypeMapping_IEnumerable_SimpleClass_PrivateCurrent ()
  1065. {
  1066. XmlTypeMapping tm = Map (typeof (SimpleClassEnumerablePrivateCurrent));
  1067. Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");
  1068. Assert.AreEqual (string.Empty, tm.Namespace, "#2");
  1069. Assert.AreEqual ("SimpleClassEnumerablePrivateCurrent", tm.TypeName, "#3");
  1070. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateCurrent", tm.TypeFullName, "#4");
  1071. tm = Map (typeof (SimpleClassEnumerablePrivateCurrent[]));
  1072. Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");
  1073. Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
  1074. #if NET_2_0
  1075. Assert.AreEqual ("ArrayOfSimpleClassEnumerablePrivateCurrent", tm.TypeName, "#A3");
  1076. #else
  1077. Assert.AreEqual ("SimpleClassEnumerablePrivateCurrent[]", tm.TypeName, "#A3");
  1078. #endif
  1079. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateCurrent[]", tm.TypeFullName, "#A4");
  1080. tm = Map (typeof (SimpleClassEnumerablePrivateCurrent[][]));
  1081. Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");
  1082. Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
  1083. #if NET_2_0
  1084. Assert.AreEqual ("ArrayOfArrayOfSimpleClassEnumerablePrivateCurrent", tm.TypeName, "#B3");
  1085. #else
  1086. Assert.AreEqual ("SimpleClassEnumerablePrivateCurrent[][]", tm.TypeName, "#B3");
  1087. #endif
  1088. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateCurrent[][]", tm.TypeFullName, "#B4");
  1089. }
  1090. [Test]
  1091. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  1092. #if ONLY_1_1
  1093. [Category ("NotDotNet")] // results in NullReferenceException in .NET 1.1 (SP1)
  1094. #endif
  1095. public void TypeMapping_IEnumerable_SimpleClass_PrivateGetEnumerator ()
  1096. {
  1097. XmlTypeMapping tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator));
  1098. Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");
  1099. Assert.AreEqual (string.Empty, tm.Namespace, "#2");
  1100. Assert.AreEqual ("SimpleClassEnumerablePrivateGetEnumerator", tm.TypeName, "#3");
  1101. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateGetEnumerator", tm.TypeFullName, "#4");
  1102. tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator[]));
  1103. Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");
  1104. Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
  1105. #if NET_2_0
  1106. Assert.AreEqual ("ArrayOfSimpleClassEnumerablePrivateGetEnumerator", tm.TypeName, "#A3");
  1107. #else
  1108. Assert.AreEqual ("SimpleClassEnumerablePrivateGetEnumerator[]", tm.TypeName, "#A3");
  1109. #endif
  1110. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateGetEnumerator[]", tm.TypeFullName, "#A4");
  1111. tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator[][]));
  1112. Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");
  1113. Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
  1114. #if NET_2_0
  1115. Assert.AreEqual ("ArrayOfArrayOfSimpleClassEnumerablePrivateGetEnumerator", tm.TypeName, "#B3");
  1116. #else
  1117. Assert.AreEqual ("SimpleClassEnumerablePrivateGetEnumerator[][]", tm.TypeName, "#B3");
  1118. #endif
  1119. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateGetEnumerator[][]", tm.TypeFullName, "#B4");
  1120. }
  1121. [Test]
  1122. [ExpectedException (typeof (InvalidOperationException))]
  1123. public void TypeMapping_ICollection_Object_NoMatchingAddMethod ()
  1124. {
  1125. Map (typeof (ObjectCollectionNoMatchingAddMethod));
  1126. }
  1127. [Test]
  1128. [ExpectedException (typeof (InvalidOperationException))]
  1129. public void TypeMapping_ICollection_Object_NoMatchingAddMethod_Array ()
  1130. {
  1131. Map (typeof (ObjectCollectionNoMatchingAddMethod[]));
  1132. }
  1133. [Test]
  1134. [ExpectedException (typeof (InvalidOperationException))]
  1135. public void TypeMapping_ICollection_SimpleClass_NoMatchingAddMethod ()
  1136. {
  1137. Map (typeof (SimpleClassCollectionNoMatchingAddMethod));
  1138. }
  1139. [Test]
  1140. [ExpectedException (typeof (InvalidOperationException))]
  1141. public void TypeMapping_ICollection_SimpleClass_NoMatchingAddMethod_Array ()
  1142. {
  1143. Map (typeof (SimpleClassCollectionNoMatchingAddMethod[]));
  1144. }
  1145. [Test]
  1146. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  1147. public void TypeMapping_ICollection_SimpleClass ()
  1148. {
  1149. XmlTypeMapping tm = Map (typeof (SimpleClassCollection));
  1150. Assert.AreEqual ("ArrayOfSimpleClass", tm.ElementName, "#1");
  1151. Assert.AreEqual (string.Empty, tm.Namespace, "#2");
  1152. Assert.AreEqual ("SimpleClassCollection", tm.TypeName, "#3");
  1153. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassCollection", tm.TypeFullName, "#4");
  1154. tm = Map (typeof (SimpleClassCollection[]));
  1155. Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.ElementName, "#A1");
  1156. Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
  1157. #if NET_2_0
  1158. Assert.AreEqual ("ArrayOfSimpleClassCollection", tm.TypeName, "#A3");
  1159. #else
  1160. Assert.AreEqual ("SimpleClassCollection[]", tm.TypeName, "#A3");
  1161. #endif
  1162. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassCollection[]", tm.TypeFullName, "#A4");
  1163. tm = Map (typeof (SimpleClassCollection[][]));
  1164. Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#B1");
  1165. Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
  1166. #if NET_2_0
  1167. Assert.AreEqual ("ArrayOfArrayOfSimpleClassCollection", tm.TypeName, "#B3");
  1168. #else
  1169. Assert.AreEqual ("SimpleClassCollection[][]", tm.TypeName, "#B3");
  1170. #endif
  1171. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassCollection[][]", tm.TypeFullName, "#B4");
  1172. }
  1173. [Test]
  1174. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  1175. public void TypeMapping_ICollection_Object ()
  1176. {
  1177. XmlTypeMapping tm = Map (typeof (ObjectCollection));
  1178. Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");
  1179. Assert.AreEqual (string.Empty, tm.Namespace, "#2");
  1180. Assert.AreEqual ("ObjectCollection", tm.TypeName, "#3");
  1181. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectCollection", tm.TypeFullName, "#4");
  1182. tm = Map (typeof (ObjectCollection[]));
  1183. Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");
  1184. Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
  1185. #if NET_2_0
  1186. Assert.AreEqual ("ArrayOfObjectCollection", tm.TypeName, "#A3");
  1187. #else
  1188. Assert.AreEqual ("ObjectCollection[]", tm.TypeName, "#A3");
  1189. #endif
  1190. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectCollection[]", tm.TypeFullName, "#A4");
  1191. tm = Map (typeof (ObjectCollection[][]));
  1192. Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");
  1193. Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
  1194. #if NET_2_0
  1195. Assert.AreEqual ("ArrayOfArrayOfObjectCollection", tm.TypeName, "#B3");
  1196. #else
  1197. Assert.AreEqual ("ObjectCollection[][]", tm.TypeName, "#B3");
  1198. #endif
  1199. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectCollection[][]", tm.TypeFullName, "#B4");
  1200. }
  1201. [Test]
  1202. [ExpectedException (typeof (InvalidOperationException))]
  1203. public void TypeMapping_ICollection_Object_NoIntIndexer ()
  1204. {
  1205. Map (typeof (ObjectCollectionNoIntIndexer));
  1206. }
  1207. [Test]
  1208. [ExpectedException (typeof (InvalidOperationException))]
  1209. public void TypeMapping_ICollection_Object_NoIntIndexer_Array ()
  1210. {
  1211. Map (typeof (ObjectCollectionNoIntIndexer[]));
  1212. }
  1213. [Test]
  1214. [ExpectedException (typeof (InvalidOperationException))]
  1215. public void TypeMapping_ICollection_SimpleClass_NoIntIndexer ()
  1216. {
  1217. Map (typeof (SimpleClassCollectionNoIntIndexer));
  1218. }
  1219. [Test]
  1220. [ExpectedException (typeof (InvalidOperationException))]
  1221. public void TypeMapping_ICollection_SimpleClass_NoIntIndexer_Array ()
  1222. {
  1223. Map (typeof (SimpleClassCollectionNoIntIndexer[]));
  1224. }
  1225. [Test]
  1226. public void TypeMapping_InvalidDefault ()
  1227. {
  1228. SoapAttributes attrs = new SoapAttributes (typeof (Field_Encoded).GetMember ("Modifiers")[0]);
  1229. attrs.SoapDefaultValue = 2; // not a defined enum value
  1230. SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
  1231. overrides.Add (typeof (Field_Encoded), "Modifiers", attrs);
  1232. try {
  1233. Map (typeof (Field_Encoded), overrides);
  1234. Assert.Fail ("#A1");
  1235. } catch (InvalidOperationException ex) {
  1236. // Enum System.Int32 cannot be converted to MonoTests.System.Xml.TestClasses.MapModifiers
  1237. Assert.IsNotNull (ex.Message, "#A2");
  1238. Assert.IsTrue (ex.Message.IndexOf (typeof (int).FullName) != -1, "#A3");
  1239. Assert.IsTrue (ex.Message.IndexOf (typeof (MapModifiers).FullName) != -1, "#A4");
  1240. Assert.IsNull (ex.InnerException, "#A5");
  1241. }
  1242. attrs.SoapDefaultValue = "2"; // not of the same type as the underlying enum type (System.Int32)
  1243. try {
  1244. Map (typeof (Field_Encoded), overrides);
  1245. Assert.Fail ("#B1");
  1246. } catch (InvalidOperationException ex) {
  1247. // Enum System.String cannot be converted to MonoTests.System.Xml.TestClasses.MapModifiers
  1248. Assert.IsNotNull (ex.Message, "#B2");
  1249. Assert.IsTrue (ex.Message.IndexOf (typeof (string).FullName) != -1, "#B3");
  1250. Assert.IsTrue (ex.Message.IndexOf (typeof (MapModifiers).FullName) != -1, "#B4");
  1251. Assert.IsNull (ex.InnerException, "#B5");
  1252. }
  1253. attrs.SoapDefaultValue = EnumDefaultValueNF.e2; // other enum type
  1254. try {
  1255. Map (typeof (Field_Encoded), overrides);
  1256. Assert.Fail ("#C1");
  1257. } catch (InvalidOperationException ex) {
  1258. // Enum MonoTests.System.Xml.TestClasses.EnumDefaultValueNF cannot be converted to MonoTests.System.Xml.TestClasses.MapModifiers
  1259. Assert.IsNotNull (ex.Message, "#C2");
  1260. Assert.IsTrue (ex.Message.IndexOf (typeof (EnumDefaultValueNF).FullName) != -1, "#C3");
  1261. Assert.IsTrue (ex.Message.IndexOf (typeof (MapModifiers).FullName) != -1, "#C4");
  1262. Assert.IsNull (ex.InnerException, "#C5");
  1263. }
  1264. attrs.SoapDefaultValue = (MapModifiers) 20; // non-existing enum value
  1265. try {
  1266. Map (typeof (Field_Encoded), overrides);
  1267. Assert.Fail ("#D1");
  1268. } catch (InvalidOperationException ex) {
  1269. // Value '20' cannot be converted to MonoTests.System.Xml.TestClasses.MapModifiers
  1270. Assert.IsNotNull (ex.Message, "#D2");
  1271. Assert.IsTrue (ex.Message.IndexOf ("'20'") != -1, "#D3");
  1272. Assert.IsTrue (ex.Message.IndexOf (typeof (MapModifiers).FullName) != -1, "#D4");
  1273. Assert.IsNull (ex.InnerException, "#D5");
  1274. }
  1275. }
  1276. [Test]
  1277. [Category ("NotWorking")]
  1278. public void TestImportMembersMapping()
  1279. {
  1280. Type type = typeof (SimpleClass);
  1281. SoapAttributes attrs = new SoapAttributes ();
  1282. SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
  1283. overrides.Add (typeof (SimpleClass), attrs);
  1284. XmlReflectionMember[] members = new XmlReflectionMember[0];
  1285. XmlMembersMapping mm;
  1286. try
  1287. {
  1288. mm = MembersMap(type, overrides, members, true, true);
  1289. Assert.Fail("Should not be able to fetch an empty XmlMembersMapping");
  1290. }
  1291. catch (Exception)
  1292. {
  1293. }
  1294. XmlReflectionMember rm = new XmlReflectionMember();
  1295. rm.IsReturnValue = false;
  1296. rm.MemberName = "something";
  1297. rm.MemberType = typeof(string);
  1298. members = new XmlReflectionMember[1];
  1299. members[0] = rm;
  1300. mm = MembersMap(type, overrides, members, false, false);
  1301. Equals(mm.Count, 1);
  1302. XmlMemberMapping smm = mm[0];
  1303. Assert.IsFalse (smm.Any, "#1");
  1304. Assert.AreEqual ("something", smm.ElementName, "#2");
  1305. Assert.AreEqual ("something", smm.MemberName, "#3");
  1306. Assert.IsNull (smm.Namespace, "#4");
  1307. Assert.AreEqual ("System.String", smm.TypeFullName, "#5");
  1308. Assert.AreEqual ("string", smm.TypeName, "#6");
  1309. Assert.AreEqual (XmlSchemaNamespace, smm.TypeNamespace, "#7");
  1310. rm = new XmlReflectionMember();
  1311. rm.IsReturnValue = false;
  1312. rm.MemberName = "nothing";
  1313. rm.MemberType = typeof(string);
  1314. members = new XmlReflectionMember[1];
  1315. members[0] = rm;
  1316. mm = MembersMap(type, overrides, members, false, false);
  1317. Assert.AreEqual (1 , mm.Count, "#8");
  1318. }
  1319. public class Employee : IXmlSerializable
  1320. {
  1321. private string _firstName;
  1322. private string _lastName;
  1323. private string _address;
  1324. public XmlSchema GetSchema ()
  1325. {
  1326. return null;
  1327. }
  1328. public void WriteXml (XmlWriter writer)
  1329. {
  1330. writer.WriteStartElement ("employee", "urn:devx-com");
  1331. writer.WriteAttributeString ("firstName", _firstName);
  1332. writer.WriteAttributeString ("lastName", _lastName);
  1333. writer.WriteAttributeString ("address", _address);
  1334. writer.WriteEndElement ();
  1335. }
  1336. public void ReadXml (XmlReader reader)
  1337. {
  1338. XmlNodeType type = reader.MoveToContent ();
  1339. if (type == XmlNodeType.Element && reader.LocalName == "employee") {
  1340. _firstName = reader["firstName"];
  1341. _lastName = reader["lastName"];
  1342. _address = reader["address"];
  1343. }
  1344. }
  1345. }
  1346. public class NestedStruct
  1347. {
  1348. public TimeSpan Period = TimeSpan.MaxValue;
  1349. }
  1350. public class ObjectEnumerable : IEnumerable
  1351. {
  1352. public void Add (int value)
  1353. {
  1354. }
  1355. public void Add (object value)
  1356. {
  1357. }
  1358. public IEnumerator GetEnumerator ()
  1359. {
  1360. return new ArrayList ().GetEnumerator ();
  1361. }
  1362. }
  1363. public class SimpleClassEnumerable : IEnumerable
  1364. {
  1365. public void Add (int value)
  1366. {
  1367. }
  1368. public void Add (object value)
  1369. {
  1370. }
  1371. IEnumerator IEnumerable.GetEnumerator ()
  1372. {
  1373. return GetEnumerator ();
  1374. }
  1375. public SimpleClassEnumerator GetEnumerator ()
  1376. {
  1377. return new SimpleClassEnumerator (new ArrayList ());
  1378. }
  1379. }
  1380. public class SimpleClassEnumerablePrivateGetEnumerator : IEnumerable
  1381. {
  1382. public void Add (object value)
  1383. {
  1384. }
  1385. IEnumerator IEnumerable.GetEnumerator ()
  1386. {
  1387. return new ArrayList ().GetEnumerator ();
  1388. }
  1389. }
  1390. public class SimpleClassEnumerablePrivateCurrent : IEnumerable
  1391. {
  1392. public void Add (object value)
  1393. {
  1394. }
  1395. IEnumerator IEnumerable.GetEnumerator ()
  1396. {
  1397. return GetEnumerator ();
  1398. }
  1399. public NoCurrentEnumerator GetEnumerator ()
  1400. {
  1401. return new NoCurrentEnumerator (new ArrayList ());
  1402. }
  1403. }
  1404. // GetEnumerator().Current returns object, but there's no corresponding
  1405. // Add (System.Object) method
  1406. public class ObjectEnumerableNoMatchingAddMethod : IEnumerable
  1407. {
  1408. public void Add (int value)
  1409. {
  1410. }
  1411. public IEnumerator GetEnumerator ()
  1412. {
  1413. return new ArrayList ().GetEnumerator ();
  1414. }
  1415. }
  1416. // GetEnumerator().Current returns SimpleClass, but there's no
  1417. // corresponding Add (SimpleClass) method
  1418. public class SimpleClassCollectionNoMatchingAddMethod : ICollection
  1419. {
  1420. public SimpleClass this[int index] {
  1421. get {
  1422. return (SimpleClass) _list[index];
  1423. }
  1424. }
  1425. public int Count {
  1426. get { return _list.Count; }
  1427. }
  1428. public bool IsSynchronized {
  1429. get { return _list.IsSynchronized; }
  1430. }
  1431. public object SyncRoot {
  1432. get { return _list.SyncRoot; }
  1433. }
  1434. public void CopyTo (Array array, int index)
  1435. {
  1436. _list.CopyTo (array, index);
  1437. }
  1438. IEnumerator IEnumerable.GetEnumerator()
  1439. {
  1440. return GetEnumerator ();
  1441. }
  1442. public SimpleClassEnumerator GetEnumerator ()
  1443. {
  1444. return new SimpleClassEnumerator (_list);
  1445. }
  1446. private ArrayList _list = new ArrayList ();
  1447. }
  1448. // GetEnumerator().Current returns object, but there's no corresponding
  1449. // Add (System.Object) method
  1450. public class ObjectCollectionNoMatchingAddMethod : ICollection
  1451. {
  1452. public object this[int index] {
  1453. get {
  1454. return _list[index];
  1455. }
  1456. }
  1457. public int Count {
  1458. get { return _list.Count; }
  1459. }
  1460. public bool IsSynchronized {
  1461. get { return _list.IsSynchronized; }
  1462. }
  1463. public object SyncRoot {
  1464. get { return _list.SyncRoot; }
  1465. }
  1466. public void CopyTo (Array array, int index)
  1467. {
  1468. _list.CopyTo (array, index);
  1469. }
  1470. IEnumerator IEnumerable.GetEnumerator ()
  1471. {
  1472. return GetEnumerator ();
  1473. }
  1474. public IEnumerator GetEnumerator ()
  1475. {
  1476. return _list.GetEnumerator ();
  1477. }
  1478. private ArrayList _list = new ArrayList ();
  1479. }
  1480. // Does not have int indexer.
  1481. public class SimpleClassCollectionNoIntIndexer : ICollection
  1482. {
  1483. public SimpleClass this[string name] {
  1484. get {
  1485. return new SimpleClass ();
  1486. }
  1487. }
  1488. public int Count {
  1489. get { return _list.Count; }
  1490. }
  1491. public bool IsSynchronized {
  1492. get { return _list.IsSynchronized; }
  1493. }
  1494. public object SyncRoot {
  1495. get { return _list.SyncRoot; }
  1496. }
  1497. public void CopyTo (Array array, int index)
  1498. {
  1499. _list.CopyTo (array, index);
  1500. }
  1501. IEnumerator IEnumerable.GetEnumerator ()
  1502. {
  1503. return GetEnumerator ();
  1504. }
  1505. public SimpleClassEnumerator GetEnumerator ()
  1506. {
  1507. return new SimpleClassEnumerator (_list);
  1508. }
  1509. public void Add (SimpleClass value)
  1510. {
  1511. _list.Add (value);
  1512. }
  1513. private ArrayList _list = new ArrayList ();
  1514. }
  1515. // Does not have int indexer.
  1516. public class ObjectCollectionNoIntIndexer : ICollection
  1517. {
  1518. public object this[string name] {
  1519. get {
  1520. return new SimpleClass ();
  1521. }
  1522. }
  1523. public int Count {
  1524. get { return _list.Count; }
  1525. }
  1526. public bool IsSynchronized {
  1527. get { return _list.IsSynchronized; }
  1528. }
  1529. public object SyncRoot {
  1530. get { return _list.SyncRoot; }
  1531. }
  1532. public void CopyTo (Array array, int index)
  1533. {
  1534. _list.CopyTo (array, index);
  1535. }
  1536. public IEnumerator GetEnumerator ()
  1537. {
  1538. return _list.GetEnumerator ();
  1539. }
  1540. public void Add (object value)
  1541. {
  1542. _list.Add (value);
  1543. }
  1544. private ArrayList _list = new ArrayList ();
  1545. }
  1546. public class SimpleClassCollection : ICollection
  1547. {
  1548. public SimpleClass this[int index] {
  1549. get {
  1550. return (SimpleClass) _list[index];
  1551. }
  1552. }
  1553. public int Count {
  1554. get { return _list.Count; }
  1555. }
  1556. public bool IsSynchronized {
  1557. get { return _list.IsSynchronized; }
  1558. }
  1559. public object SyncRoot {
  1560. get { return _list.SyncRoot; }
  1561. }
  1562. public void CopyTo (Array array, int index)
  1563. {
  1564. _list.CopyTo (array, index);
  1565. }
  1566. IEnumerator IEnumerable.GetEnumerator ()
  1567. {
  1568. return GetEnumerator ();
  1569. }
  1570. public SimpleClassEnumerator GetEnumerator ()
  1571. {
  1572. return new SimpleClassEnumerator (_list);
  1573. }
  1574. public void Add (SimpleClass value)
  1575. {
  1576. _list.Add (value);
  1577. }
  1578. private ArrayList _list = new ArrayList ();
  1579. }
  1580. public class ObjectCollection : ICollection
  1581. {
  1582. public object this[int name] {
  1583. get {
  1584. return new SimpleClass ();
  1585. }
  1586. }
  1587. public int Count
  1588. {
  1589. get { return _list.Count; }
  1590. }
  1591. public bool IsSynchronized
  1592. {
  1593. get { return _list.IsSynchronized; }
  1594. }
  1595. public object SyncRoot
  1596. {
  1597. get { return _list.SyncRoot; }
  1598. }
  1599. public void CopyTo (Array array, int index)
  1600. {
  1601. _list.CopyTo (array, index);
  1602. }
  1603. public IEnumerator GetEnumerator ()
  1604. {
  1605. return _list.GetEnumerator ();
  1606. }
  1607. public void Add (object value)
  1608. {
  1609. _list.Add (value);
  1610. }
  1611. private ArrayList _list = new ArrayList ();
  1612. }
  1613. public class SimpleClassEnumerator : IEnumerator
  1614. {
  1615. internal SimpleClassEnumerator (ArrayList arguments)
  1616. {
  1617. IEnumerable temp = (IEnumerable) (arguments);
  1618. _baseEnumerator = temp.GetEnumerator ();
  1619. }
  1620. public SimpleClass Current
  1621. {
  1622. get { return (SimpleClass) _baseEnumerator.Current; }
  1623. }
  1624. object IEnumerator.Current
  1625. {
  1626. get { return _baseEnumerator.Current; }
  1627. }
  1628. public bool MoveNext ()
  1629. {
  1630. return _baseEnumerator.MoveNext ();
  1631. }
  1632. bool IEnumerator.MoveNext ()
  1633. {
  1634. return _baseEnumerator.MoveNext ();
  1635. }
  1636. public void Reset ()
  1637. {
  1638. _baseEnumerator.Reset ();
  1639. }
  1640. void IEnumerator.Reset ()
  1641. {
  1642. _baseEnumerator.Reset ();
  1643. }
  1644. private IEnumerator _baseEnumerator;
  1645. }
  1646. public class NoCurrentEnumerator : IEnumerator
  1647. {
  1648. internal NoCurrentEnumerator (ArrayList arguments)
  1649. {
  1650. IEnumerable temp = (IEnumerable) (arguments);
  1651. _baseEnumerator = temp.GetEnumerator ();
  1652. }
  1653. object IEnumerator.Current
  1654. {
  1655. get { return _baseEnumerator.Current; }
  1656. }
  1657. public bool MoveNext ()
  1658. {
  1659. return _baseEnumerator.MoveNext ();
  1660. }
  1661. bool IEnumerator.MoveNext ()
  1662. {
  1663. return _baseEnumerator.MoveNext ();
  1664. }
  1665. public void Reset ()
  1666. {
  1667. _baseEnumerator.Reset ();
  1668. }
  1669. void IEnumerator.Reset ()
  1670. {
  1671. _baseEnumerator.Reset ();
  1672. }
  1673. private IEnumerator _baseEnumerator;
  1674. }
  1675. }
  1676. }