HttpWriter.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //
  2. // HttpWriter.cs - HttpWriter tests.
  3. //
  4. // Author:
  5. // Miguel de Icaza ([email protected])
  6. //
  7. // Copyright (C) 2006 Novell, Inc (http://www.novell.com)
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining
  10. // a copy of this software and associated documentation files (the
  11. // "Software"), to deal in the Software without restriction, including
  12. // without limitation the rights to use, copy, modify, merge, publish,
  13. // distribute, sublicense, and/or sell copies of the Software, and to
  14. // permit persons to whom the Software is furnished to do so, subject to
  15. // the following conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. //
  28. using NUnit.Framework;
  29. using System;
  30. using System.Collections;
  31. using System.IO;
  32. using System.Reflection;
  33. using System.Text;
  34. using System.Web;
  35. using System.Web.Caching;
  36. namespace MonoCasTests.System.Web {
  37. [TestFixture]
  38. public class HttpWriterTest {
  39. private HttpWriter writer;
  40. [TestFixtureSetUp]
  41. public void FixtureSetUp ()
  42. {
  43. HttpContext context = new HttpContext (null);
  44. writer = (HttpWriter) context.Response.Output;
  45. }
  46. [Test]
  47. public void NullWrites ()
  48. {
  49. object null_object = null;
  50. string null_string = null;
  51. writer.Write (null_string);
  52. writer.Write (null_object);
  53. writer.WriteString (null, 0, 0);
  54. }
  55. [Test]
  56. [ExpectedException (typeof (ArgumentOutOfRangeException))]
  57. public void NullBufferException ()
  58. {
  59. writer.Write (null, 0, 0);
  60. }
  61. [Test]
  62. [ExpectedException (typeof (ArgumentOutOfRangeException))]
  63. public void WriteInvalidArg1 ()
  64. {
  65. char [] x = new char [] { 'a' };
  66. writer.Write (x, -1, 0);
  67. }
  68. [Test]
  69. [ExpectedException (typeof (ArgumentOutOfRangeException))]
  70. public void WriteInvalidArg2 ()
  71. {
  72. char [] x = new char [] { 'a' };
  73. writer.Write (x, 0, -1);
  74. }
  75. [Test]
  76. [ExpectedException (typeof (ArgumentOutOfRangeException))]
  77. public void WriteStringInvalidArg1 ()
  78. {
  79. writer.WriteString ("hello", 0, -1);
  80. }
  81. [Test]
  82. [ExpectedException (typeof (ArgumentOutOfRangeException))]
  83. public void WriteStringInvalidArg2 ()
  84. {
  85. writer.Write ("hello", -1, 0);
  86. }
  87. [Test]
  88. [ExpectedException (typeof (ArgumentOutOfRangeException))]
  89. public void WriteStringInvalidArg3 ()
  90. {
  91. writer.Write ("hello", 0, 10);
  92. }
  93. }
  94. }