I am performing some unit tests and want my MembershipProvider to initialize the dependencies. I run the following code before any test is executed [TestFixtureSetup]. 
public static void StructureMapConfiguration()
        {
            ObjectFactory.Initialize(InitializeUsingScanning);
        }
        private static void InitializeUsingScanning(IInitializationExpression obj)
        {
            obj.Scan(
                x =>
                    {
                        x.Assembly("EStudyMongoDb.Business");
                        x.WithDefaultConventions();
                    }
                );
        }
Here is my EstablishContext method which is triggered before running any test: 
 public override void EstablishContext()
        {
            _provider = ObjectFactory.GetInstance<MongoDbMembershipProvider>(); 
            _config.Add("applicationName", "EStudyApplication");
            _config.Add("name", "EStudyMembershipProvider");
            _config.Add("requiresQuestionAndAnswer", "false");
            _provider.Initialize(_config["name"], _config);
        } 
Here is my test: 
 [TestFixture]
    public class when_creating_a_new_user : specification_for_membership_provider 
    {         
        public override void When()
        {
            _user = _provider.CreateUser("johndoe", "password", "
[email protected]", String.Empty, String.Empty,
              true, null, out _status);
        }
        [Test]        
        public void should_create_successfully()
        {
            var vUser = Membership.GetUser(_user.UserName);
            Assert.IsNotNull(vUser);             
        }
    }
Now, in the Membership.GetUser method I try to access the _userRepository but I get null.