SoapReflectionImporterTests.cs 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808
  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. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  911. public void TypeMapping_IEnumerable_SimpleClass ()
  912. {
  913. XmlTypeMapping tm = Map (typeof (SimpleClassEnumerable));
  914. Assert.AreEqual ("ArrayOfSimpleClass", tm.ElementName, "#1");
  915. Assert.AreEqual (string.Empty, tm.Namespace, "#2");
  916. Assert.AreEqual ("SimpleClassEnumerable", tm.TypeName, "#3");
  917. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerable", tm.TypeFullName, "#4");
  918. tm = Map (typeof (SimpleClassEnumerable[]));
  919. Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.ElementName, "#A1");
  920. Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
  921. #if NET_2_0
  922. Assert.AreEqual ("ArrayOfSimpleClassEnumerable", tm.TypeName, "#A3");
  923. #else
  924. Assert.AreEqual ("SimpleClassEnumerable[]", tm.TypeName, "#A3");
  925. #endif
  926. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerable[]", tm.TypeFullName, "#A4");
  927. tm = Map (typeof (SimpleClassEnumerable[][]));
  928. Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#B1");
  929. Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
  930. #if NET_2_0
  931. Assert.AreEqual ("ArrayOfArrayOfSimpleClassEnumerable", tm.TypeName, "#B3");
  932. #else
  933. Assert.AreEqual ("SimpleClassEnumerable[][]", tm.TypeName, "#B3");
  934. #endif
  935. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerable[][]", tm.TypeFullName, "#B4");
  936. }
  937. [Test]
  938. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  939. public void TypeMapping_IEnumerable_Object ()
  940. {
  941. XmlTypeMapping tm = Map (typeof (ObjectEnumerable));
  942. Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");
  943. Assert.AreEqual (string.Empty, tm.Namespace, "#2");
  944. Assert.AreEqual ("ObjectEnumerable", tm.TypeName, "#3");
  945. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectEnumerable", tm.TypeFullName, "#4");
  946. tm = Map (typeof (ObjectEnumerable[]));
  947. Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");
  948. Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
  949. #if NET_2_0
  950. Assert.AreEqual ("ArrayOfObjectEnumerable", tm.TypeName, "#A3");
  951. #else
  952. Assert.AreEqual ("ObjectEnumerable[]", tm.TypeName, "#A3");
  953. #endif
  954. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectEnumerable[]", tm.TypeFullName, "#A4");
  955. tm = Map (typeof (ObjectEnumerable[][]));
  956. Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");
  957. Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
  958. #if NET_2_0
  959. Assert.AreEqual ("ArrayOfArrayOfObjectEnumerable", tm.TypeName, "#B3");
  960. #else
  961. Assert.AreEqual ("ObjectEnumerable[][]", tm.TypeName, "#B3");
  962. #endif
  963. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectEnumerable[][]", tm.TypeFullName, "#B4");
  964. }
  965. [Test]
  966. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  967. [ExpectedException (typeof (InvalidOperationException))]
  968. public void TypeMapping_IEnumerable_Object_NoMatchingAddMethod ()
  969. {
  970. Map (typeof (ObjectEnumerableNoMatchingAddMethod));
  971. }
  972. [Test]
  973. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  974. [ExpectedException (typeof (InvalidOperationException))]
  975. public void TypeMapping_IEnumerable_Object_NoMatchingAddMethod_Array ()
  976. {
  977. Map (typeof (ObjectEnumerableNoMatchingAddMethod[]));
  978. }
  979. [Test]
  980. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  981. public void TypeMapping_IEnumerable_SimpleClass_PrivateCurrent ()
  982. {
  983. XmlTypeMapping tm = Map (typeof (SimpleClassEnumerablePrivateCurrent));
  984. Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");
  985. Assert.AreEqual (string.Empty, tm.Namespace, "#2");
  986. Assert.AreEqual ("SimpleClassEnumerablePrivateCurrent", tm.TypeName, "#3");
  987. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateCurrent", tm.TypeFullName, "#4");
  988. tm = Map (typeof (SimpleClassEnumerablePrivateCurrent[]));
  989. Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");
  990. Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
  991. #if NET_2_0
  992. Assert.AreEqual ("ArrayOfSimpleClassEnumerablePrivateCurrent", tm.TypeName, "#A3");
  993. #else
  994. Assert.AreEqual ("SimpleClassEnumerablePrivateCurrent[]", tm.TypeName, "#A3");
  995. #endif
  996. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateCurrent[]", tm.TypeFullName, "#A4");
  997. tm = Map (typeof (SimpleClassEnumerablePrivateCurrent[][]));
  998. Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");
  999. Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
  1000. #if NET_2_0
  1001. Assert.AreEqual ("ArrayOfArrayOfSimpleClassEnumerablePrivateCurrent", tm.TypeName, "#B3");
  1002. #else
  1003. Assert.AreEqual ("SimpleClassEnumerablePrivateCurrent[][]", tm.TypeName, "#B3");
  1004. #endif
  1005. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateCurrent[][]", tm.TypeFullName, "#B4");
  1006. }
  1007. [Test]
  1008. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  1009. #if ONLY_1_1
  1010. [Category ("NotDotNet")] // results in NullReferenceException in .NET 1.1 (SP1)
  1011. #endif
  1012. public void TypeMapping_IEnumerable_SimpleClass_PrivateGetEnumerator ()
  1013. {
  1014. XmlTypeMapping tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator));
  1015. Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");
  1016. Assert.AreEqual (string.Empty, tm.Namespace, "#2");
  1017. Assert.AreEqual ("SimpleClassEnumerablePrivateGetEnumerator", tm.TypeName, "#3");
  1018. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateGetEnumerator", tm.TypeFullName, "#4");
  1019. tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator[]));
  1020. Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");
  1021. Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
  1022. #if NET_2_0
  1023. Assert.AreEqual ("ArrayOfSimpleClassEnumerablePrivateGetEnumerator", tm.TypeName, "#A3");
  1024. #else
  1025. Assert.AreEqual ("SimpleClassEnumerablePrivateGetEnumerator[]", tm.TypeName, "#A3");
  1026. #endif
  1027. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateGetEnumerator[]", tm.TypeFullName, "#A4");
  1028. tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator[][]));
  1029. Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");
  1030. Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
  1031. #if NET_2_0
  1032. Assert.AreEqual ("ArrayOfArrayOfSimpleClassEnumerablePrivateGetEnumerator", tm.TypeName, "#B3");
  1033. #else
  1034. Assert.AreEqual ("SimpleClassEnumerablePrivateGetEnumerator[][]", tm.TypeName, "#B3");
  1035. #endif
  1036. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassEnumerablePrivateGetEnumerator[][]", tm.TypeFullName, "#B4");
  1037. }
  1038. [Test]
  1039. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  1040. [ExpectedException (typeof (InvalidOperationException))]
  1041. public void TypeMapping_ICollection_Object_NoMatchingAddMethod ()
  1042. {
  1043. Map (typeof (ObjectCollectionNoMatchingAddMethod));
  1044. }
  1045. [Test]
  1046. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  1047. [ExpectedException (typeof (InvalidOperationException))]
  1048. public void TypeMapping_ICollection_Object_NoMatchingAddMethod_Array ()
  1049. {
  1050. Map (typeof (ObjectCollectionNoMatchingAddMethod[]));
  1051. }
  1052. [Test]
  1053. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  1054. [ExpectedException (typeof (InvalidOperationException))]
  1055. public void TypeMapping_ICollection_SimpleClass_NoMatchingAddMethod ()
  1056. {
  1057. Map (typeof (SimpleClassCollectionNoMatchingAddMethod));
  1058. }
  1059. [Test]
  1060. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  1061. [ExpectedException (typeof (InvalidOperationException))]
  1062. public void TypeMapping_ICollection_SimpleClass_NoMatchingAddMethod_Array ()
  1063. {
  1064. Map (typeof (SimpleClassCollectionNoMatchingAddMethod[]));
  1065. }
  1066. [Test]
  1067. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  1068. public void TypeMapping_ICollection_SimpleClass ()
  1069. {
  1070. XmlTypeMapping tm = Map (typeof (SimpleClassCollection));
  1071. Assert.AreEqual ("ArrayOfSimpleClass", tm.ElementName, "#1");
  1072. Assert.AreEqual (string.Empty, tm.Namespace, "#2");
  1073. Assert.AreEqual ("SimpleClassCollection", tm.TypeName, "#3");
  1074. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassCollection", tm.TypeFullName, "#4");
  1075. tm = Map (typeof (SimpleClassCollection[]));
  1076. Assert.AreEqual ("ArrayOfArrayOfSimpleClass", tm.ElementName, "#A1");
  1077. Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
  1078. #if NET_2_0
  1079. Assert.AreEqual ("ArrayOfSimpleClassCollection", tm.TypeName, "#A3");
  1080. #else
  1081. Assert.AreEqual ("SimpleClassCollection[]", tm.TypeName, "#A3");
  1082. #endif
  1083. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassCollection[]", tm.TypeFullName, "#A4");
  1084. tm = Map (typeof (SimpleClassCollection[][]));
  1085. Assert.AreEqual ("ArrayOfArrayOfArrayOfSimpleClass", tm.ElementName, "#B1");
  1086. Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
  1087. #if NET_2_0
  1088. Assert.AreEqual ("ArrayOfArrayOfSimpleClassCollection", tm.TypeName, "#B3");
  1089. #else
  1090. Assert.AreEqual ("SimpleClassCollection[][]", tm.TypeName, "#B3");
  1091. #endif
  1092. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.SimpleClassCollection[][]", tm.TypeFullName, "#B4");
  1093. }
  1094. [Test]
  1095. [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
  1096. public void TypeMapping_ICollection_Object ()
  1097. {
  1098. XmlTypeMapping tm = Map (typeof (ObjectCollection));
  1099. Assert.AreEqual ("ArrayOfAnyType", tm.ElementName, "#1");
  1100. Assert.AreEqual (string.Empty, tm.Namespace, "#2");
  1101. Assert.AreEqual ("ObjectCollection", tm.TypeName, "#3");
  1102. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectCollection", tm.TypeFullName, "#4");
  1103. tm = Map (typeof (ObjectCollection[]));
  1104. Assert.AreEqual ("ArrayOfArrayOfAnyType", tm.ElementName, "#A1");
  1105. Assert.AreEqual (string.Empty, tm.Namespace, "#A2");
  1106. #if NET_2_0
  1107. Assert.AreEqual ("ArrayOfObjectCollection", tm.TypeName, "#A3");
  1108. #else
  1109. Assert.AreEqual ("ObjectCollection[]", tm.TypeName, "#A3");
  1110. #endif
  1111. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectCollection[]", tm.TypeFullName, "#A4");
  1112. tm = Map (typeof (ObjectCollection[][]));
  1113. Assert.AreEqual ("ArrayOfArrayOfArrayOfAnyType", tm.ElementName, "#B1");
  1114. Assert.AreEqual (string.Empty, tm.Namespace, "#B2");
  1115. #if NET_2_0
  1116. Assert.AreEqual ("ArrayOfArrayOfObjectCollection", tm.TypeName, "#B3");
  1117. #else
  1118. Assert.AreEqual ("ObjectCollection[][]", tm.TypeName, "#B3");
  1119. #endif
  1120. Assert.AreEqual ("MonoTests.System.XmlSerialization.SoapReflectionImporterTests.ObjectCollection[][]", tm.TypeFullName, "#B4");
  1121. }
  1122. [Test]
  1123. [ExpectedException (typeof (InvalidOperationException))]
  1124. public void TypeMapping_ICollection_Object_NoIntIndexer ()
  1125. {
  1126. Map (typeof (ObjectCollectionNoIntIndexer));
  1127. }
  1128. [Test]
  1129. [ExpectedException (typeof (InvalidOperationException))]
  1130. public void TypeMapping_ICollection_Object_NoIntIndexer_Array ()
  1131. {
  1132. Map (typeof (ObjectCollectionNoIntIndexer[]));
  1133. }
  1134. [Test]
  1135. [ExpectedException (typeof (InvalidOperationException))]
  1136. public void TypeMapping_ICollection_SimpleClass_NoIntIndexer ()
  1137. {
  1138. Map (typeof (SimpleClassCollectionNoIntIndexer));
  1139. }
  1140. [Test]
  1141. [ExpectedException (typeof (InvalidOperationException))]
  1142. public void TypeMapping_ICollection_SimpleClass_NoIntIndexer_Array ()
  1143. {
  1144. Map (typeof (SimpleClassCollectionNoIntIndexer[]));
  1145. }
  1146. [Test]
  1147. [Category ("NotWorking")]
  1148. public void TestImportMembersMapping()
  1149. {
  1150. Type type = typeof (SimpleClass);
  1151. SoapAttributes attrs = new SoapAttributes ();
  1152. SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
  1153. overrides.Add (typeof (SimpleClass), attrs);
  1154. XmlReflectionMember[] members = new XmlReflectionMember[0];
  1155. XmlMembersMapping mm;
  1156. try
  1157. {
  1158. mm = MembersMap(type, overrides, members, true, true);
  1159. Assert.Fail("Should not be able to fetch an empty XmlMembersMapping");
  1160. }
  1161. catch (Exception)
  1162. {
  1163. }
  1164. XmlReflectionMember rm = new XmlReflectionMember();
  1165. rm.IsReturnValue = false;
  1166. rm.MemberName = "something";
  1167. rm.MemberType = typeof(string);
  1168. members = new XmlReflectionMember[1];
  1169. members[0] = rm;
  1170. mm = MembersMap(type, overrides, members, false, false);
  1171. Equals(mm.Count, 1);
  1172. XmlMemberMapping smm = mm[0];
  1173. Assert.IsFalse (smm.Any, "#1");
  1174. Assert.AreEqual ("something", smm.ElementName, "#2");
  1175. Assert.AreEqual ("something", smm.MemberName, "#3");
  1176. Assert.IsNull (smm.Namespace, "#4");
  1177. Assert.AreEqual ("System.String", smm.TypeFullName, "#5");
  1178. Assert.AreEqual ("string", smm.TypeName, "#6");
  1179. Assert.AreEqual (XmlSchemaNamespace, smm.TypeNamespace, "#7");
  1180. rm = new XmlReflectionMember();
  1181. rm.IsReturnValue = false;
  1182. rm.MemberName = "nothing";
  1183. rm.MemberType = typeof(string);
  1184. members = new XmlReflectionMember[1];
  1185. members[0] = rm;
  1186. mm = MembersMap(type, overrides, members, false, false);
  1187. Assert.AreEqual (1 , mm.Count, "#8");
  1188. }
  1189. public class Employee : IXmlSerializable
  1190. {
  1191. private string _firstName;
  1192. private string _lastName;
  1193. private string _address;
  1194. public XmlSchema GetSchema ()
  1195. {
  1196. return null;
  1197. }
  1198. public void WriteXml (XmlWriter writer)
  1199. {
  1200. writer.WriteStartElement ("employee", "urn:devx-com");
  1201. writer.WriteAttributeString ("firstName", _firstName);
  1202. writer.WriteAttributeString ("lastName", _lastName);
  1203. writer.WriteAttributeString ("address", _address);
  1204. writer.WriteEndElement ();
  1205. }
  1206. public void ReadXml (XmlReader reader)
  1207. {
  1208. XmlNodeType type = reader.MoveToContent ();
  1209. if (type == XmlNodeType.Element && reader.LocalName == "employee") {
  1210. _firstName = reader["firstName"];
  1211. _lastName = reader["lastName"];
  1212. _address = reader["address"];
  1213. }
  1214. }
  1215. }
  1216. public class NestedStruct
  1217. {
  1218. public TimeSpan Period = TimeSpan.MaxValue;
  1219. }
  1220. public class ObjectEnumerable : IEnumerable
  1221. {
  1222. public void Add (int value)
  1223. {
  1224. }
  1225. public void Add (object value)
  1226. {
  1227. }
  1228. public IEnumerator GetEnumerator ()
  1229. {
  1230. return new ArrayList ().GetEnumerator ();
  1231. }
  1232. }
  1233. public class SimpleClassEnumerable : IEnumerable
  1234. {
  1235. public void Add (int value)
  1236. {
  1237. }
  1238. public void Add (object value)
  1239. {
  1240. }
  1241. IEnumerator IEnumerable.GetEnumerator ()
  1242. {
  1243. return GetEnumerator ();
  1244. }
  1245. public SimpleClassEnumerator GetEnumerator ()
  1246. {
  1247. return new SimpleClassEnumerator (new ArrayList ());
  1248. }
  1249. }
  1250. public class SimpleClassEnumerablePrivateGetEnumerator : IEnumerable
  1251. {
  1252. public void Add (object value)
  1253. {
  1254. }
  1255. IEnumerator IEnumerable.GetEnumerator ()
  1256. {
  1257. return new ArrayList ().GetEnumerator ();
  1258. }
  1259. }
  1260. public class SimpleClassEnumerablePrivateCurrent : IEnumerable
  1261. {
  1262. public void Add (object value)
  1263. {
  1264. }
  1265. IEnumerator IEnumerable.GetEnumerator ()
  1266. {
  1267. return GetEnumerator ();
  1268. }
  1269. public NoCurrentEnumerator GetEnumerator ()
  1270. {
  1271. return new NoCurrentEnumerator (new ArrayList ());
  1272. }
  1273. }
  1274. // GetEnumerator().Current returns object, but there's no corresponding
  1275. // Add (System.Object) method
  1276. public class ObjectEnumerableNoMatchingAddMethod : IEnumerable
  1277. {
  1278. public void Add (int value)
  1279. {
  1280. }
  1281. public IEnumerator GetEnumerator ()
  1282. {
  1283. return new ArrayList ().GetEnumerator ();
  1284. }
  1285. }
  1286. // GetEnumerator().Current returns SimpleClass, but there's no
  1287. // corresponding Add (SimpleClass) method
  1288. public class SimpleClassCollectionNoMatchingAddMethod : ICollection
  1289. {
  1290. public SimpleClass this[int index] {
  1291. get {
  1292. return (SimpleClass) _list[index];
  1293. }
  1294. }
  1295. public int Count {
  1296. get { return _list.Count; }
  1297. }
  1298. public bool IsSynchronized {
  1299. get { return _list.IsSynchronized; }
  1300. }
  1301. public object SyncRoot {
  1302. get { return _list.SyncRoot; }
  1303. }
  1304. public void CopyTo (Array array, int index)
  1305. {
  1306. _list.CopyTo (array, index);
  1307. }
  1308. IEnumerator IEnumerable.GetEnumerator()
  1309. {
  1310. return GetEnumerator ();
  1311. }
  1312. public SimpleClassEnumerator GetEnumerator ()
  1313. {
  1314. return new SimpleClassEnumerator (_list);
  1315. }
  1316. private ArrayList _list = new ArrayList ();
  1317. }
  1318. // GetEnumerator().Current returns object, but there's no corresponding
  1319. // Add (System.Object) method
  1320. public class ObjectCollectionNoMatchingAddMethod : ICollection
  1321. {
  1322. public object this[int index] {
  1323. get {
  1324. return _list[index];
  1325. }
  1326. }
  1327. public int Count {
  1328. get { return _list.Count; }
  1329. }
  1330. public bool IsSynchronized {
  1331. get { return _list.IsSynchronized; }
  1332. }
  1333. public object SyncRoot {
  1334. get { return _list.SyncRoot; }
  1335. }
  1336. public void CopyTo (Array array, int index)
  1337. {
  1338. _list.CopyTo (array, index);
  1339. }
  1340. IEnumerator IEnumerable.GetEnumerator ()
  1341. {
  1342. return GetEnumerator ();
  1343. }
  1344. public IEnumerator GetEnumerator ()
  1345. {
  1346. return _list.GetEnumerator ();
  1347. }
  1348. private ArrayList _list = new ArrayList ();
  1349. }
  1350. // Does not have int indexer.
  1351. public class SimpleClassCollectionNoIntIndexer : ICollection
  1352. {
  1353. public SimpleClass this[string name] {
  1354. get {
  1355. return new SimpleClass ();
  1356. }
  1357. }
  1358. public int Count {
  1359. get { return _list.Count; }
  1360. }
  1361. public bool IsSynchronized {
  1362. get { return _list.IsSynchronized; }
  1363. }
  1364. public object SyncRoot {
  1365. get { return _list.SyncRoot; }
  1366. }
  1367. public void CopyTo (Array array, int index)
  1368. {
  1369. _list.CopyTo (array, index);
  1370. }
  1371. IEnumerator IEnumerable.GetEnumerator ()
  1372. {
  1373. return GetEnumerator ();
  1374. }
  1375. public SimpleClassEnumerator GetEnumerator ()
  1376. {
  1377. return new SimpleClassEnumerator (_list);
  1378. }
  1379. public void Add (SimpleClass value)
  1380. {
  1381. _list.Add (value);
  1382. }
  1383. private ArrayList _list = new ArrayList ();
  1384. }
  1385. // Does not have int indexer.
  1386. public class ObjectCollectionNoIntIndexer : ICollection
  1387. {
  1388. public object this[string name] {
  1389. get {
  1390. return new SimpleClass ();
  1391. }
  1392. }
  1393. public int Count {
  1394. get { return _list.Count; }
  1395. }
  1396. public bool IsSynchronized {
  1397. get { return _list.IsSynchronized; }
  1398. }
  1399. public object SyncRoot {
  1400. get { return _list.SyncRoot; }
  1401. }
  1402. public void CopyTo (Array array, int index)
  1403. {
  1404. _list.CopyTo (array, index);
  1405. }
  1406. public IEnumerator GetEnumerator ()
  1407. {
  1408. return _list.GetEnumerator ();
  1409. }
  1410. public void Add (object value)
  1411. {
  1412. _list.Add (value);
  1413. }
  1414. private ArrayList _list = new ArrayList ();
  1415. }
  1416. public class SimpleClassCollection : ICollection
  1417. {
  1418. public SimpleClass this[int index] {
  1419. get {
  1420. return (SimpleClass) _list[index];
  1421. }
  1422. }
  1423. public int Count {
  1424. get { return _list.Count; }
  1425. }
  1426. public bool IsSynchronized {
  1427. get { return _list.IsSynchronized; }
  1428. }
  1429. public object SyncRoot {
  1430. get { return _list.SyncRoot; }
  1431. }
  1432. public void CopyTo (Array array, int index)
  1433. {
  1434. _list.CopyTo (array, index);
  1435. }
  1436. IEnumerator IEnumerable.GetEnumerator ()
  1437. {
  1438. return GetEnumerator ();
  1439. }
  1440. public SimpleClassEnumerator GetEnumerator ()
  1441. {
  1442. return new SimpleClassEnumerator (_list);
  1443. }
  1444. public void Add (SimpleClass value)
  1445. {
  1446. _list.Add (value);
  1447. }
  1448. private ArrayList _list = new ArrayList ();
  1449. }
  1450. public class ObjectCollection : ICollection
  1451. {
  1452. public object this[int name] {
  1453. get {
  1454. return new SimpleClass ();
  1455. }
  1456. }
  1457. public int Count
  1458. {
  1459. get { return _list.Count; }
  1460. }
  1461. public bool IsSynchronized
  1462. {
  1463. get { return _list.IsSynchronized; }
  1464. }
  1465. public object SyncRoot
  1466. {
  1467. get { return _list.SyncRoot; }
  1468. }
  1469. public void CopyTo (Array array, int index)
  1470. {
  1471. _list.CopyTo (array, index);
  1472. }
  1473. public IEnumerator GetEnumerator ()
  1474. {
  1475. return _list.GetEnumerator ();
  1476. }
  1477. public void Add (object value)
  1478. {
  1479. _list.Add (value);
  1480. }
  1481. private ArrayList _list = new ArrayList ();
  1482. }
  1483. public class SimpleClassEnumerator : IEnumerator
  1484. {
  1485. internal SimpleClassEnumerator (ArrayList arguments)
  1486. {
  1487. IEnumerable temp = (IEnumerable) (arguments);
  1488. _baseEnumerator = temp.GetEnumerator ();
  1489. }
  1490. public SimpleClass Current
  1491. {
  1492. get { return (SimpleClass) _baseEnumerator.Current; }
  1493. }
  1494. object IEnumerator.Current
  1495. {
  1496. get { return _baseEnumerator.Current; }
  1497. }
  1498. public bool MoveNext ()
  1499. {
  1500. return _baseEnumerator.MoveNext ();
  1501. }
  1502. bool IEnumerator.MoveNext ()
  1503. {
  1504. return _baseEnumerator.MoveNext ();
  1505. }
  1506. public void Reset ()
  1507. {
  1508. _baseEnumerator.Reset ();
  1509. }
  1510. void IEnumerator.Reset ()
  1511. {
  1512. _baseEnumerator.Reset ();
  1513. }
  1514. private IEnumerator _baseEnumerator;
  1515. }
  1516. public class NoCurrentEnumerator : IEnumerator
  1517. {
  1518. internal NoCurrentEnumerator (ArrayList arguments)
  1519. {
  1520. IEnumerable temp = (IEnumerable) (arguments);
  1521. _baseEnumerator = temp.GetEnumerator ();
  1522. }
  1523. object IEnumerator.Current
  1524. {
  1525. get { return _baseEnumerator.Current; }
  1526. }
  1527. public bool MoveNext ()
  1528. {
  1529. return _baseEnumerator.MoveNext ();
  1530. }
  1531. bool IEnumerator.MoveNext ()
  1532. {
  1533. return _baseEnumerator.MoveNext ();
  1534. }
  1535. public void Reset ()
  1536. {
  1537. _baseEnumerator.Reset ();
  1538. }
  1539. void IEnumerator.Reset ()
  1540. {
  1541. _baseEnumerator.Reset ();
  1542. }
  1543. private IEnumerator _baseEnumerator;
  1544. }
  1545. }
  1546. }