Using Sitecore Users in your unit tests

Hyper quick post for the morning πŸ˜€ – I have once again been tasked with security related work in Sitecore. I know there are many approaches to this – wrapping, Virtual Users (which requires dummy config) , but on this occasion (have done it a few times before too) I am not particularly interested in interrogating the user once I have finished with it – just ‘mocking’ / stubbing one as an argument or a return. So I thought I use this:

    public class TestUser : User
    {
        public TestUser(string name, bool isAuthenticated)
            : base(name, isAuthenticated)
        {

        }
    }

Works a treat πŸ˜€

Advertisements

2 thoughts on “Using Sitecore Users in your unit tests

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s