Ok, so we have an asp.net server control
The server control internally calls a method to Load the Authenticated User. It HAD System.Web.HttpContext.Current hardcoded in this method, but I extracted that out to a property to allow me to pass in my own mocked version (I assume thats what JustMock does)?
So the question is...how do I go about Mocking this? Because I need this Unit Test to pass :) I want GetAuthenticatedProfile to return me an MppProfile object of my choosing as this test doesnt need to go through all of the MembershipUser bits.
Am I even doing this right? Should it be simpler in that I pass in an isTest bool and just ignore this part of the method if isTest is true?
                                The server control internally calls a method to Load the Authenticated User. It HAD System.Web.HttpContext.Current hardcoded in this method, but I extracted that out to a property to allow me to pass in my own mocked version (I assume thats what JustMock does)?
protected override MppProfile GetAuthenticatedProfile(){    if (this.LoadAuthenticated && _authenticatedProfile == null) {        try        {            if (this.Context.User != null)            {                try {                    foreach (MembershipProvider mp in Membership.Providers) {                        MembershipUser user = mp.GetUser(Context.User.Identity.Name, false);                        if (user != null) {                            _authenticatedProfile = AuthDBContext.MppProfiles.SingleOrDefault(x => x.AspnetUser.UserName == user.UserName);                            break;                        }                    }                } catch (ConfigurationErrorsException ex) {                    System.Diagnostics.Debug.WriteLine(ex.Message);                    throw new Exception(ex.BareMessage);                }            }        }        catch (ArgumentException ex)        {            System.Diagnostics.Debug.WriteLine(ex.Message);            // No authenticated user        }        catch (SqlException ex)        {            throw ex;        }        catch (Exception ex)        {            System.Diagnostics.Debug.WriteLine(ex.Message);            throw new InvalidOperationException("Membership must be configured to load the authenticated user. Either configure a membership provider or set LoadAuthenticated=false.");        }    }    return _authenticatedProfile;}So the question is...how do I go about Mocking this? Because I need this Unit Test to pass :) I want GetAuthenticatedProfile to return me an MppProfile object of my choosing as this test doesnt need to go through all of the MembershipUser bits.
Am I even doing this right? Should it be simpler in that I pass in an isTest bool and just ignore this part of the method if isTest is true?

