public void DeleteUser() { System.Web.Security.MembershipCreateStatus status; MembershipUser user = System.Web.Security.Membership.CreateUser("user1", "password", "*****@*****.**", "question?", "yes", true, out status); System.Configuration.SettingsContext sc = new System.Configuration.SettingsContext(); sc.Add("UserName", "user1"); sc.Add("IsAuthenticated", true); System.Configuration.SettingsPropertyValueCollection properties = new System.Configuration.SettingsPropertyValueCollection(); var propVal = new System.Configuration.SettingsPropertyValue( new System.Configuration.SettingsProperty("Test") { DefaultValue = "", PropertyType = typeof(string) } ); propVal.PropertyValue = "test string"; properties.Add(propVal); ProfileManager.Provider.SetPropertyValues(sc, properties); Assert.Equal(System.Web.Security.MembershipCreateStatus.Success, status); System.Web.Security.Membership.DeleteUser("user1"); }
public void SetPropertyValues() { User p = new User() { Application = app, IsAnonymous = false, UserName = "******" }; p.Save(); System.Configuration.SettingsContext sc = new System.Configuration.SettingsContext(); sc.Add("UserName", "user1"); sc.Add("IsAuthenticated", true); System.Configuration.SettingsPropertyValueCollection properties = new System.Configuration.SettingsPropertyValueCollection(); var propVal = new System.Configuration.SettingsPropertyValue( new System.Configuration.SettingsProperty("Test") { DefaultValue = "", PropertyType=typeof(string)} ); propVal.PropertyValue = "test string"; properties.Add(propVal); ProfileManager.Provider.SetPropertyValues(sc, properties); User.Evict(p.ID); User u2 = User.Load(p.ID); Assert.Equal(p.ID, u2.Profile.ID); }
public void SetPropertyValuesAnonnymous() { System.Configuration.SettingsContext sc = new System.Configuration.SettingsContext(); sc.Add("UserName", new Guid().ToString()); sc.Add("IsAuthenticated", false); System.Configuration.SettingsPropertyValueCollection properties = new System.Configuration.SettingsPropertyValueCollection(); var nSettingsProp = new System.Configuration.SettingsProperty("Test") { DefaultValue = "", PropertyType = typeof(string) }; nSettingsProp.Attributes.Add("AllowAnonymous", true); var propVal = new System.Configuration.SettingsPropertyValue( nSettingsProp ); propVal.PropertyValue = "test string"; properties.Add(propVal); ProfileManager.Provider.SetPropertyValues(sc, properties); }
public void saveProfile(string user, bool saveUser) { if (saveUser) { User p = new User() { Application = app, IsAnonymous = false, UserName = user }; p.Save(); } System.Configuration.SettingsContext sc = new System.Configuration.SettingsContext(); sc.Add("UserName", user); sc.Add("IsAuthenticated", true); System.Configuration.SettingsPropertyValueCollection properties = new System.Configuration.SettingsPropertyValueCollection(); var propVal = new System.Configuration.SettingsPropertyValue( new System.Configuration.SettingsProperty("Test") { DefaultValue = "", PropertyType = typeof(string) } ); propVal.PropertyValue = "test string"; properties.Add(propVal); ProfileManager.Provider.SetPropertyValues(sc, properties); }