private MySQLProfileProvider InitProfileProvider() { MySQLProfileProvider p = new MySQLProfileProvider(); NameValueCollection config = new NameValueCollection(); config.Add("connectionStringName", "LocalMySqlServer"); config.Add("applicationName", "/"); p.Initialize(null, config); return p; }
/// <summary> /// We have to manually reset the app id because our profile provider is loaded from /// previous tests but we are destroying our database between tests. This means that /// our provider thinks we have an application in our database when we really don't. /// Doing this will force the provider to generate a new app id. /// Note that this is not really a problem in a normal app that is not destroying /// the database behind the back of the provider. /// </summary> /// <param name="p"></param> private void ResetAppId(MySQLProfileProvider p) { Type t = p.GetType(); FieldInfo fi = t.GetField("app", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.GetField); object appObject = fi.GetValue(p); Type appType = appObject.GetType(); PropertyInfo pi = appType.GetProperty("Id"); pi.SetValue(appObject, -1, null); }
/// <summary> /// We have to manually reset the app id because our profile provider is loaded from /// previous tests but we are destroying our database between tests. This means that /// our provider thinks we have an application in our database when we really don't. /// Doing this will force the provider to generate a new app id. /// Note that this is not really a problem in a normal app that is not destroying /// the database behind the back of the provider. /// </summary> /// <param name="p"></param> private void ResetAppId(MySQLProfileProvider p) { Type t = p.GetType(); FieldInfo fi = t.GetField("applicationId", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.GetField); fi.SetValue(p, -1); }