当前位置: 首页>>代码示例>>C#>>正文


C# Class1.SetValue方法代码示例

本文整理汇总了C#中Class1.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Class1.SetValue方法的具体用法?C# Class1.SetValue怎么用?C# Class1.SetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Class1的用法示例。


在下文中一共展示了Class1.SetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetValue_Causes_Validation

        public void SetValue_Causes_Validation()
        {
            var target = new Class1();

            target.SetValue(Class1.QuxProperty, 5);
            Assert.Throws<ArgumentOutOfRangeException>(() => target.SetValue(Class1.QuxProperty, 25));
            Assert.Equal(5, target.GetValue(Class1.QuxProperty));
        }
开发者ID:Robertofon,项目名称:Perspex,代码行数:8,代码来源:PerspexObjectTests_Validation.cs

示例2: Setting_UnsetValue_Reverts_To_Default_Value

        public void Setting_UnsetValue_Reverts_To_Default_Value()
        {
            Class1 target = new Class1();

            target.SetValue(Class1.FooProperty, "newvalue");
            target.SetValue(Class1.FooProperty, PerspexProperty.UnsetValue);

            Assert.Equal("foodefault", target.GetValue(Class1.FooProperty));
        }
开发者ID:Robertofon,项目名称:Perspex,代码行数:9,代码来源:PerspexObjectTests_SetValue.cs

示例3: IsSet_Returns_False_For_Cleared_Property

        public void IsSet_Returns_False_For_Cleared_Property()
        {
            var target = new Class1();

            target.SetValue(Class1.FooProperty, "foo");
            target.SetValue(Class1.FooProperty, PerspexProperty.UnsetValue);

            Assert.False(target.IsSet(Class1.FooProperty));
        }
开发者ID:Arlorean,项目名称:Perspex,代码行数:9,代码来源:PerspexObjectTests_Metadata.cs

示例4: SetValue_Causes_Coercion

        public void SetValue_Causes_Coercion()
        {
            var target = new Class1();

            target.SetValue(Class1.QuxProperty, 5);
            Assert.Equal(5, target.GetValue(Class1.QuxProperty));
            target.SetValue(Class1.QuxProperty, -5);
            Assert.Equal(0, target.GetValue(Class1.QuxProperty));
            target.SetValue(Class1.QuxProperty, 15);
            Assert.Equal(10, target.GetValue(Class1.QuxProperty));
        }
开发者ID:Robertofon,项目名称:Perspex,代码行数:11,代码来源:PerspexObjectTests_Validation.cs

示例5: SetValue_Doesnt_Raise_PropertyChanged_If_Value_Not_Changed

        public void SetValue_Doesnt_Raise_PropertyChanged_If_Value_Not_Changed()
        {
            Class1 target = new Class1();
            bool raised = false;

            target.SetValue(Class1.FooProperty, "bar");

            target.PropertyChanged += (s, e) =>
            {
                raised = true;
            };

            target.SetValue(Class1.FooProperty, "bar");

            Assert.False(raised);
        }
开发者ID:,项目名称:,代码行数:16,代码来源:

示例6: SetValue_Sets_Value_NonGeneric

        public void SetValue_Sets_Value_NonGeneric()
        {
            var target = new Class1();

            target.SetValue((PerspexProperty)Class1.FooProperty, "newvalue");

            Assert.Equal("newvalue", target.Foo);
        }
开发者ID:rdterner,项目名称:Perspex,代码行数:8,代码来源:PerspexObjectTests_Direct.cs

示例7: SetValue_Sets_Value

        public void SetValue_Sets_Value()
        {
            Class1 target = new Class1();

            target.SetValue(Class1.FooProperty, "newvalue");

            Assert.Equal("newvalue", target.GetValue(Class1.FooProperty));
        }
开发者ID:,项目名称:,代码行数:8,代码来源:

示例8: IsSet_Returns_False_For_Set_Property

        public void IsSet_Returns_False_For_Set_Property()
        {
            var target = new Class1();

            target.SetValue(Class1.FooProperty, "foo");

            Assert.True(target.IsSet(Class1.FooProperty));
        }
开发者ID:Arlorean,项目名称:Perspex,代码行数:8,代码来源:PerspexObjectTests_Metadata.cs

示例9: Setting_Non_Validated_Direct_Property_Does_Not_Call_UpdateDataValidation

        public void Setting_Non_Validated_Direct_Property_Does_Not_Call_UpdateDataValidation()
        {
            var target = new Class1();

            target.SetValue(Class1.NonValidatedDirectProperty, 6);

            Assert.Empty(target.Notifications);
        }
开发者ID:jkoritzinsky,项目名称:Avalonia,代码行数:8,代码来源:AvaloniaObjectTests_DataValidation.cs

示例10: SetValue_NonGeneric_Coerces_UnsetValue_To_Default_Value

        public void SetValue_NonGeneric_Coerces_UnsetValue_To_Default_Value()
        {
            var target = new Class1();

            target.SetValue((PerspexProperty)Class1.BazProperty, PerspexProperty.UnsetValue);

            Assert.Equal(0, target.Baz);
        }
开发者ID:rdterner,项目名称:Perspex,代码行数:8,代码来源:PerspexObjectTests_Direct.cs

示例11: ClearValue_Clears_Value

        public void ClearValue_Clears_Value()
        {
            Class1 target = new Class1();

            target.SetValue(Class1.FooProperty, "newvalue");
            target.ClearValue(Class1.FooProperty);

            Assert.Equal("foodefault", target.GetValue(Class1.FooProperty));
        }
开发者ID:,项目名称:,代码行数:9,代码来源:

示例12: Revalidate_Causes_Recoercion

        public void Revalidate_Causes_Recoercion()
        {
            var target = new Class1();

            target.SetValue(Class1.QuxProperty, 7);
            Assert.Equal(7, target.GetValue(Class1.QuxProperty));
            target.MaxQux = 5;
            target.Revalidate(Class1.QuxProperty);
        }
开发者ID:Robertofon,项目名称:Perspex,代码行数:9,代码来源:PerspexObjectTests_Validation.cs

示例13: GetValue_Returns_Inherited_Value

        public void GetValue_Returns_Inherited_Value()
        {
            Class1 parent = new Class1();
            Class2 child = new Class2 { Parent = parent };

            parent.SetValue(Class1.BazProperty, "changed");

            Assert.Equal("changed", child.GetValue(Class1.BazProperty));
        }
开发者ID:KvanTTT,项目名称:Perspex,代码行数:9,代码来源:PerspexObjectTests_GetValue.cs

示例14: Changed_Observable_Fired

        public void Changed_Observable_Fired()
        {
            var target = new Class1();
            string value = null;

            Class1.FooProperty.Changed.Subscribe(x => value = (string)x.NewValue);
            target.SetValue(Class1.FooProperty, "newvalue");

            Assert.Equal("newvalue", value);
        }
开发者ID:Scellow,项目名称:Perspex,代码行数:10,代码来源:PerspexPropertyTests.cs

示例15: Setting_Validated_Direct_Property_Calls_UpdateDataValidation

        public void Setting_Validated_Direct_Property_Calls_UpdateDataValidation()
        {
            var target = new Class1();

            target.SetValue(Class1.ValidatedDirectProperty, new BindingNotification(6));
            target.SetValue(Class1.ValidatedDirectProperty, new BindingNotification(new Exception(), BindingErrorType.Error));
            target.SetValue(Class1.ValidatedDirectProperty, new BindingNotification(new Exception(), BindingErrorType.DataValidationError));
            target.SetValue(Class1.ValidatedDirectProperty, new BindingNotification(7));

            Assert.Equal(
                new[]
                {
                    new BindingNotification(6),
                    new BindingNotification(new Exception(), BindingErrorType.Error),
                    new BindingNotification(new Exception(), BindingErrorType.DataValidationError),
                    new BindingNotification(7),
                },
                target.Notifications.AsEnumerable());
        }
开发者ID:jkoritzinsky,项目名称:Avalonia,代码行数:19,代码来源:AvaloniaObjectTests_DataValidation.cs


注:本文中的Class1.SetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。