XmlSerializerImplementationTests.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. //
  2. // XmlSerializerImplementation.cs
  3. //
  4. // Author:
  5. // Atsushi Enomoto <[email protected]>
  6. //
  7. // Copyright (C) 2006 Novell, Inc.
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. #if NET_2_0
  30. using System;
  31. using System.Collections;
  32. using System.Xml.Serialization;
  33. using NUnit.Framework;
  34. namespace MonoTests.System.XmlSerialization
  35. {
  36. [TestFixture]
  37. public class XmlSerializerImplementationTests
  38. {
  39. class MyImplementation : XmlSerializerImplementation
  40. {
  41. }
  42. [Test]
  43. [ExpectedException (typeof (NotSupportedException))]
  44. public void DefaultReder ()
  45. {
  46. MyImplementation impl = new MyImplementation ();
  47. Assert.IsNull (impl.Reader, "#1");
  48. }
  49. [Test]
  50. [ExpectedException (typeof (NotSupportedException))]
  51. public void DefaultRederMethods ()
  52. {
  53. MyImplementation impl = new MyImplementation ();
  54. Assert.IsNull (impl.ReadMethods, "#2");
  55. }
  56. [Test]
  57. [ExpectedException (typeof (NotSupportedException))]
  58. public void DefaultWriter ()
  59. {
  60. MyImplementation impl = new MyImplementation ();
  61. Assert.IsNull (impl.Writer, "#3");
  62. }
  63. [Test]
  64. [ExpectedException (typeof (NotSupportedException))]
  65. public void DefaultWriteMethods ()
  66. {
  67. MyImplementation impl = new MyImplementation ();
  68. Assert.IsNull (impl.WriteMethods, "#4");
  69. }
  70. [Test]
  71. [ExpectedException (typeof (NotSupportedException))]
  72. public void DefaultTypedSerializers ()
  73. {
  74. MyImplementation impl = new MyImplementation ();
  75. Assert.IsNull (impl.TypedSerializers, "#5");
  76. }
  77. [Test]
  78. [ExpectedException (typeof (NotSupportedException))]
  79. public void CanSerialize ()
  80. {
  81. MyImplementation impl = new MyImplementation ();
  82. Assert.IsTrue (impl.CanSerialize (typeof (int)), "#1");
  83. }
  84. [Test]
  85. [ExpectedException (typeof (NotSupportedException))]
  86. public void GetSerializer ()
  87. {
  88. MyImplementation impl = new MyImplementation ();
  89. Assert.IsNull (impl.GetSerializer (typeof (int)), "#1");
  90. }
  91. [Test]
  92. [ExpectedException (typeof (NotSupportedException))]
  93. public void GetSerializer2 ()
  94. {
  95. MyImplementation2 impl = new MyImplementation2 ();
  96. impl.TypedSerializers [typeof (int)] = new XmlSerializer (typeof (int));
  97. XmlSerializer ser = impl.GetSerializer (typeof (int));
  98. }
  99. class MyImplementation2 : XmlSerializerImplementation
  100. {
  101. Hashtable serializers = new Hashtable ();
  102. public override Hashtable TypedSerializers {
  103. get { return serializers; }
  104. }
  105. }
  106. }
  107. }
  108. #endif