AdCreatedEventArgsTest.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. //
  2. // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining
  5. // a copy of this software and associated documentation files (the
  6. // "Software"), to deal in the Software without restriction, including
  7. // without limitation the rights to use, copy, modify, merge, publish,
  8. // distribute, sublicense, and/or sell copies of the Software, and to
  9. // permit persons to whom the Software is furnished to do so, subject to
  10. // the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be
  13. // included in all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  19. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  20. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  21. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. //
  23. //
  24. // System.Web.UI.WebControls.AdCreatedEventArgsTest.cs
  25. //
  26. // Author:
  27. // Jackson Harper ([email protected])
  28. //
  29. using System;
  30. using System.Collections;
  31. using System.Web.UI.WebControls;
  32. using NUnit.Framework;
  33. namespace MonoTests.System.Web.UI {
  34. [TestFixture]
  35. public class AdCreatedEventArgsTest {
  36. [Test]
  37. public void Defaults ()
  38. {
  39. Hashtable table = new Hashtable ();
  40. AdCreatedEventArgs e = new AdCreatedEventArgs (table);
  41. Assert.AreEqual (e.AdProperties, table, "Constructor");
  42. e = new AdCreatedEventArgs (null);
  43. Assert.AreEqual (e.AdProperties, null, "Null Constructor");
  44. }
  45. [Test]
  46. public void SetPropsInCtor ()
  47. {
  48. Hashtable table = new Hashtable ();
  49. table ["AlternateText"] = "alt text";
  50. table ["ImageUrl"] = "image url";
  51. table ["NavigateUrl"] = "nav url";
  52. AdCreatedEventArgs e = new AdCreatedEventArgs (table);
  53. Assert.AreEqual (e.AlternateText, "alt text", "alt text");
  54. Assert.AreEqual (e.ImageUrl, "image url", "image url");
  55. Assert.AreEqual (e.NavigateUrl, "nav url", "nav url");
  56. }
  57. [Test]
  58. public void SetProps ()
  59. {
  60. AdCreatedEventArgs e = new AdCreatedEventArgs (null);
  61. e.AlternateText = "alt text";
  62. Assert.AreEqual (e.AlternateText, "alt text", "alt text");
  63. e.AlternateText = null;
  64. Assert.AreEqual (e.AlternateText, null, "null alt text");
  65. e.ImageUrl = "image url";
  66. Assert.AreEqual (e.ImageUrl, "image url", "image url");
  67. e.ImageUrl = null;
  68. Assert.AreEqual (e.ImageUrl, null, "null image url");
  69. e.NavigateUrl = "nav url";
  70. Assert.AreEqual (e.NavigateUrl, "nav url", "nav url");
  71. e.NavigateUrl = null;
  72. Assert.AreEqual (e.NavigateUrl, null, "null nav url");
  73. }
  74. [Test]
  75. public void ModifyProps ()
  76. {
  77. Hashtable table = new Hashtable ();
  78. table ["AlternateText"] = "alt text";
  79. table ["ImageUrl"] = "image url";
  80. table ["NavigateUrl"] = "nav url";
  81. AdCreatedEventArgs e = new AdCreatedEventArgs (table);
  82. e.AlternateText = "foo";
  83. Assert.AreEqual (e.AdProperties ["AlternateText"],
  84. "alt text", "alt text");
  85. e.ImageUrl = "bar";
  86. Assert.AreEqual (e.AdProperties ["ImageUrl"],
  87. "image url", "image url");
  88. e.NavigateUrl = "baz";
  89. Assert.AreEqual (e.AdProperties ["NavigateUrl"],
  90. "nav url", "nav url");
  91. }
  92. [Test]
  93. [ExpectedException (typeof (InvalidCastException))]
  94. public void BadCastAlternateText ()
  95. {
  96. Hashtable table = new Hashtable ();
  97. table ["AlternateText"] = 52;
  98. AdCreatedEventArgs e = new AdCreatedEventArgs (table);
  99. }
  100. [Test]
  101. [ExpectedException (typeof (InvalidCastException))]
  102. public void BadCastImageUrl ()
  103. {
  104. Hashtable table = new Hashtable ();
  105. table ["ImageUrl"] = 52;
  106. AdCreatedEventArgs e = new AdCreatedEventArgs (table);
  107. }
  108. [Test]
  109. [ExpectedException (typeof (InvalidCastException))]
  110. public void BadCastNavigateUrl ()
  111. {
  112. Hashtable table = new Hashtable ();
  113. table ["NavigateUrl"] = 52;
  114. AdCreatedEventArgs e = new AdCreatedEventArgs (table);
  115. }
  116. }
  117. }