I created an extension method HasContentPermissionon System.Security.Principal.IIdentity:
namespace System.Security.Principal
{
public static class IdentityExtensions
{
public static bool HasContentPermission
(this IIdentity identity, int contentID)
{
return result;
}
}
}
And I call it this way:
bool hasPermission = User.Identity.HasPermission(contentID);
It works like a charm. Now I want to unit test it. To do this, I really just need to call the extension method, therefore:
using System.Security.Principal;
namespace MyUnitTests
{
[TestMethod]
public void HasContentPermission_PermissionRecordExists_ReturnsTrue()
{
IIdentity identity;
bool result = identity.HasContentPermission(...
But HasContentPermissionthere will be no intellisense. I tried to create a stub class that inherits from IIdentity, but that didn't work either. Why?
Or am I mistaken about this?
source
share