Ejemplo n.º 1
0
        public void AnonymousUserSettingNonAnonymousProperties()
        {
            MySQLProfileProvider provider = InitProfileProvider();
            SettingsContext      ctx      = new SettingsContext();

            ctx.Add("IsAuthenticated", false);
            ctx.Add("UserName", "user1");

            SettingsPropertyValueCollection values = new SettingsPropertyValueCollection();
            SettingsProperty property1             = new SettingsProperty("color");

            property1.PropertyType = typeof(string);
            property1.Attributes["AllowAnonymous"] = false;
            SettingsPropertyValue value = new SettingsPropertyValue(property1);

            value.PropertyValue = "blue";
            values.Add(value);

            provider.SetPropertyValues(ctx, values);

            DataTable dt = FillTable("SELECT * FROM my_aspnet_Applications");

            Assert.AreEqual(0, dt.Rows.Count);
            dt = FillTable("SELECT * FROM my_aspnet_Users");
            Assert.AreEqual(0, dt.Rows.Count);
            dt = FillTable("SELECT * FROM my_aspnet_Profiles");
            Assert.AreEqual(0, dt.Rows.Count);
        }
Ejemplo n.º 2
0
        public void SettingValuesCreatesAnAppAndUserId()
        {
            MySQLProfileProvider provider = InitProfileProvider();
            SettingsContext      ctx      = new SettingsContext();

            ctx.Add("IsAuthenticated", false);
            ctx.Add("UserName", "user1");

            SettingsPropertyValueCollection values = new SettingsPropertyValueCollection();
            SettingsProperty property1             = new SettingsProperty("color");

            property1.PropertyType = typeof(string);
            property1.Attributes["AllowAnonymous"] = true;
            SettingsPropertyValue value = new SettingsPropertyValue(property1);

            value.PropertyValue = "blue";
            values.Add(value);

            provider.SetPropertyValues(ctx, values);

            DataTable dt = FillTable("SELECT * FROM my_aspnet_applications");

            Assert.True(1 == dt.Rows.Count, "Rows count on table my_aspnet_applications is not 1");

            dt = FillTable("SELECT * FROM my_aspnet_users");
            Assert.True(1 == dt.Rows.Count, "Rows count on table my_aspnet_users is not 1");


            dt = FillTable("SELECT * FROM my_aspnet_profiles");
            Assert.True(1 == dt.Rows.Count, "Rows count on table my_aspnet_profiles is not 1");

            values["color"].PropertyValue = "green";
            provider.SetPropertyValues(ctx, values);

            dt = FillTable("SELECT * FROM my_aspnet_applications");
            Assert.True(1 == dt.Rows.Count, "Rows count on table my_aspnet_applications is not 1 after setting property");

            dt = FillTable("SELECT * FROM my_aspnet_users");
            Assert.True(1 == dt.Rows.Count, "Rows count on table my_aspnet_users is not 1 after setting property");

            dt = FillTable("SELECT * FROM my_aspnet_profiles");
            Assert.True(1 == dt.Rows.Count, "Rows count on table my_aspnet_profiles is not 1 after setting property");
        }