SoapReflectionImporterTests.cs 60 KB

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