SoapReflectionImporterTests.cs 46 KB

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