本文整理汇总了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));
}
示例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));
}
示例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));
}
示例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));
}
示例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);
}
示例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);
}
示例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));
}
示例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));
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
示例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));
}
示例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);
}
示例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());
}