-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
177 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
MongoMembership.Tests/Providers/RoleProvider/When_AddUsersToRoles_is_called.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using Machine.Specifications; | ||
using MongoMembership.Providers; | ||
|
||
namespace MongoMembership.Tests.Providers.RoleProvider | ||
{ | ||
[Subject(typeof(MongoRoleProvider))] | ||
internal class When_AddUsersToRoles_is_called : ProvidersStubs | ||
{ | ||
Establish conext = () => | ||
{ | ||
admin = "AdmiN"; | ||
guest = "GueSt"; | ||
banned = "bannned"; | ||
username1 = "username1"; | ||
username2 = "username2"; | ||
username3 = "username3"; | ||
|
||
MongoMembershipProvider membershipProvider = CreateMembershipProvider(); | ||
|
||
provider = CreateRoleProvider(); | ||
provider.CreateRole(admin); | ||
provider.CreateRole(guest); | ||
provider.CreateRole(banned); | ||
AddUser(membershipProvider, username1); | ||
AddUser(membershipProvider, username2); | ||
AddUser(membershipProvider, username3); | ||
}; | ||
|
||
Because of = () => | ||
{ | ||
provider.AddUsersToRoles(new[] { username1, username2 }, new[] { admin }); | ||
provider.AddUsersToRoles(new[] { username1, username2, username3 }, new[] { guest }); | ||
provider.AddUsersToRoles(new[] { username3 }, new[] { banned }); | ||
}; | ||
|
||
It should_return_true_for__username1__and__admin__role = () => | ||
provider.IsUserInRole(username1, admin).ShouldBeTrue(); | ||
|
||
It should_return_true_for__username1__and__guest__role = () => | ||
provider.IsUserInRole(username1, guest).ShouldBeTrue(); | ||
|
||
It should_return_false_for__username1__and__banned__role = () => | ||
provider.IsUserInRole(username1, banned).ShouldBeFalse(); | ||
|
||
It should_return_false_for__username3__and__admin__role = () => | ||
provider.IsUserInRole(username3, admin).ShouldBeFalse(); | ||
|
||
It should_return_true_for__username3__and__guest__role = () => | ||
provider.IsUserInRole(username3, guest).ShouldBeTrue(); | ||
|
||
It should_return_true_for__username3__and__banned__role = () => | ||
provider.IsUserInRole(username3, banned).ShouldBeTrue(); | ||
|
||
private static MongoRoleProvider provider; | ||
private static string admin; | ||
private static string guest; | ||
private static string banned; | ||
private static string username1; | ||
private static string username2; | ||
private static string username3; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
MongoMembership.Tests/Providers/RoleProvider/When_DeleteRole_is_called_and_role_exist.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Machine.Specifications; | ||
using MongoMembership.Providers; | ||
|
||
namespace MongoMembership.Tests.Providers.RoleProvider | ||
{ | ||
[Subject(typeof(MongoRoleProvider))] | ||
internal class When_DeleteRole_is_called_and_role_exist : ProvidersStubs | ||
{ | ||
Establish conext = () => | ||
{ | ||
roleName = "AdmiN"; | ||
provider = CreateRoleProvider(); | ||
provider.CreateRole(roleName); | ||
}; | ||
|
||
Because of = () => | ||
provider.DeleteRole(roleName, false); | ||
|
||
It should_delete_role = () => | ||
provider.GetAllRoles().ShouldBeEmpty(); | ||
|
||
private static MongoRoleProvider provider; | ||
private static string roleName; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
MongoMembership.Tests/Providers/RoleProvider/When_DeleteRole_is_called_and_role_not_exist.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using Machine.Specifications; | ||
using MongoMembership.Providers; | ||
|
||
namespace MongoMembership.Tests.Providers.RoleProvider | ||
{ | ||
[Subject(typeof(MongoRoleProvider))] | ||
internal class When_DeleteRole_is_called_and_role_not_exist : ProvidersStubs | ||
{ | ||
Establish conext = () => | ||
{ | ||
provider = CreateRoleProvider(); | ||
}; | ||
|
||
Because of = () => | ||
exception = Catch.Exception(() => provider.DeleteRole("NotAdmiN", false)); | ||
|
||
It should_not_fail = () => | ||
exception.ShouldBeNull(); | ||
|
||
private static MongoRoleProvider provider; | ||
private static Exception exception; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...embership.Tests/Providers/RoleProvider/When_GetAllRoles_is_called_and_one_role_created.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Machine.Specifications; | ||
using MongoMembership.Providers; | ||
|
||
namespace MongoMembership.Tests.Providers.RoleProvider | ||
{ | ||
[Subject(typeof(MongoRoleProvider))] | ||
internal class When_GetAllRoles_is_called_and_one_role_created : ProvidersStubs | ||
{ | ||
Establish conext = () => | ||
{ | ||
roleName = "AdmiN"; | ||
provider = CreateRoleProvider(); | ||
provider.CreateRole(roleName); | ||
}; | ||
|
||
Because of = () => | ||
result = provider.GetAllRoles(); | ||
|
||
It should_return_same_role = () => | ||
result.ShouldContainOnly(new[] { roleName }); | ||
|
||
private static MongoRoleProvider provider; | ||
private static string roleName; | ||
private static string[] result; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...roviders/RoleProvider/When_GetAllRoles_is_called_and_roles__Admin__and__AdmiN__created.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Machine.Specifications; | ||
using MongoMembership.Providers; | ||
|
||
namespace MongoMembership.Tests.Providers.RoleProvider | ||
{ | ||
[Subject(typeof(MongoRoleProvider))] | ||
internal class When_GetAllRoles_is_called_and_roles__Admin__and__AdmiN__created : ProvidersStubs | ||
{ | ||
Establish conext = () => | ||
{ | ||
provider = CreateRoleProvider(); | ||
AdmiN = "AdmiN"; | ||
provider.CreateRole(AdmiN); | ||
provider.CreateRole("Admin"); | ||
}; | ||
|
||
Because of = () => | ||
result = provider.GetAllRoles(); | ||
|
||
It should_only__AdmiN__ = () => | ||
result.ShouldContainOnly(new[] { AdmiN }); | ||
|
||
private static MongoRoleProvider provider; | ||
private static string AdmiN; | ||
private static string[] result; | ||
} | ||
} |