SoapReflectionImporterTests.cs 55 KB

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