2
0

RolePrincipalTest.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. //
  2. // MembershipUserCollectionTest.cs
  3. // - Unit tests for System.Web.Security.MembershipUserCollection
  4. //
  5. // Author:
  6. // Sebastien Pouliot <[email protected]>
  7. //
  8. // Copyright (C) 2005 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 System;
  31. using System.Configuration.Provider;
  32. using System.Security.Principal;
  33. using System.Web.Security;
  34. using NUnit.Framework;
  35. namespace MonoTests.System.Web.Security {
  36. public class TestRoleProvider : RoleProvider {
  37. public override void AddUsersToRoles (string[] usernames, string[] roleNames)
  38. {
  39. throw new Exception ("The method or operation is not implemented.");
  40. }
  41. public override string ApplicationName
  42. {
  43. get
  44. {
  45. throw new Exception ("The method or operation is not implemented.");
  46. }
  47. set
  48. {
  49. throw new Exception ("The method or operation is not implemented.");
  50. }
  51. }
  52. public override void CreateRole (string roleName)
  53. {
  54. throw new Exception ("The method or operation is not implemented.");
  55. }
  56. public override bool DeleteRole (string roleName, bool throwOnPopulatedRole)
  57. {
  58. throw new Exception ("The method or operation is not implemented.");
  59. }
  60. public override string[] FindUsersInRole (string roleName, string usernameToMatch)
  61. {
  62. throw new Exception ("The method or operation is not implemented.");
  63. }
  64. public override string[] GetAllRoles ()
  65. {
  66. throw new Exception ("The method or operation is not implemented.");
  67. }
  68. public override string[] GetRolesForUser (string username)
  69. {
  70. throw new Exception ("The method or operation is not implemented.");
  71. }
  72. public override string[] GetUsersInRole (string roleName)
  73. {
  74. throw new Exception ("The method or operation is not implemented.");
  75. }
  76. public override bool IsUserInRole (string username, string roleName)
  77. {
  78. throw new Exception ("The method or operation is not implemented.");
  79. }
  80. public override void RemoveUsersFromRoles (string[] usernames, string[] roleNames)
  81. {
  82. throw new Exception ("The method or operation is not implemented.");
  83. }
  84. public override bool RoleExists (string roleName)
  85. {
  86. throw new Exception ("The method or operation is not implemented.");
  87. }
  88. }
  89. [TestFixture]
  90. public class RolePrincipalTest {
  91. private IIdentity GetGenericIdentity (string name)
  92. {
  93. return new GenericIdentity (name);
  94. }
  95. [Test]
  96. [ExpectedException (typeof (ArgumentNullException))]
  97. public void Contructor_Identity_Null ()
  98. {
  99. RolePrincipal rp = new RolePrincipal (null);
  100. }
  101. [Test]
  102. [ExpectedException (typeof (ProviderException))]
  103. [Category ("NotWorking")]
  104. public void Contructor_Identity ()
  105. {
  106. RolePrincipal rp = new RolePrincipal (GetGenericIdentity ("me"));
  107. }
  108. }
  109. }
  110. #endif