SoapReflectionImporterTests.cs 56 KB

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