TestUrlPropertyAttribute.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //
  2. // Tests for System.Web.UI.UrlPropertyAttribute.cs
  3. //
  4. // Author:
  5. // Sanjay Gupta ([email protected])
  6. //
  7. //
  8. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  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 NUnit.Framework;
  31. using System;
  32. using System.Web;
  33. using System.Web.UI;
  34. using System.Collections;
  35. using System.ComponentModel;
  36. using System.IO;
  37. namespace MonoTests.System.Web.UI
  38. {
  39. [TestFixture]
  40. public class UrlPropertyAttributeTest
  41. {
  42. UrlPropertyAttribute upa;
  43. UrlPropertyAttribute upa1;
  44. UrlPropertyAttribute upa2;
  45. string filter;
  46. UrlTypes urlTypes;
  47. [TearDown]
  48. public void TearDown () {}
  49. [SetUp]
  50. public void SetUp ()
  51. {
  52. filter = "filter";
  53. urlTypes = UrlTypes.DocRelative;
  54. upa = new UrlPropertyAttribute ();
  55. upa1 = new UrlPropertyAttribute (filter);
  56. upa2 = new UrlPropertyAttribute (filter, urlTypes);
  57. }
  58. [Test]
  59. public void TestFilter ()
  60. {
  61. Assert.AreEqual (upa.Filter, "*.*", "Filter#1");
  62. Assert.AreEqual (upa1.Filter, filter, "Filter#2");
  63. Assert.AreEqual (upa2.Filter, filter, "Filter#3");
  64. }
  65. [Test]
  66. public void TestAllowedTypes ()
  67. {
  68. UrlTypes types = UrlTypes.Absolute |
  69. UrlTypes.AppRelative |
  70. UrlTypes.DocRelative |
  71. UrlTypes.RootRelative;
  72. Assert.AreEqual (upa.AllowedTypes, types, "Types#1");
  73. Assert.AreEqual (upa1.AllowedTypes, types, "Types#2");
  74. Assert.AreEqual (upa2.AllowedTypes, urlTypes, "Types#3");
  75. }
  76. [Test]
  77. public void TestGetHashCode ()
  78. {
  79. string filter1 = "*.*";
  80. Assert.AreEqual (upa.GetHashCode (), filter1.GetHashCode (), "GHC#1");
  81. Assert.AreEqual (upa1.GetHashCode (), filter.GetHashCode (), "GHC#2");
  82. }
  83. [Test]
  84. public void TestEquals ()
  85. {
  86. upa = new UrlPropertyAttribute ("sanjay");
  87. Assert.IsFalse (upa.Equals (upa2), "Equals#1");
  88. //Assert.IsTrue (upa.Equals (upa1), "Equals#2");
  89. Assert.IsFalse (upa1.Equals (upa2), "Equals#3");
  90. upa1 = new UrlPropertyAttribute ("sanjay", UrlTypes.Absolute);
  91. Assert.IsFalse (upa2.Equals (upa1), "Equals#4");
  92. upa1 = new UrlPropertyAttribute ("sanjay", UrlTypes.DocRelative);
  93. //Assert.IsTrue (upa2.Equals (upa1), "Equals#5");
  94. }
  95. }
  96. }
  97. #endif