本文整理汇总了C#中Property.SetValueAsInitial方法的典型用法代码示例。如果您正苦于以下问题:C# Property.SetValueAsInitial方法的具体用法?C# Property.SetValueAsInitial怎么用?C# Property.SetValueAsInitial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Property
的用法示例。
在下文中一共展示了Property.SetValueAsInitial方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HasChangedShouldBeFalseAfterInitialValueIsSet
public void HasChangedShouldBeFalseAfterInitialValueIsSet()
{
// arrange
var property = new Property<int>();
// act
property.Value = 1;
property.SetValueAsInitial();
// assert
Assert.IsFalse(property.HasChanged());
Assert.AreEqual(1, property.InitialValue);
Assert.AreEqual(1, property.Value);
}
示例2: HasChangedShouldBeTrueAfterInitialValueIsSetAndChanged
public void HasChangedShouldBeTrueAfterInitialValueIsSetAndChanged()
{
// arrange
var property = new Property<int>();
// act
property.Value = 1;
property.SetValueAsInitial();
property.Value = 2;
// assert
Assert.True(property.HasChanged());
Assert.Equal(1, property.InitialValue);
Assert.Equal(2, property.Value);
}
示例3: HasChangedShouldBeTrueAfterInitialValueIsSetAndOtherItemIsAdded
public void HasChangedShouldBeTrueAfterInitialValueIsSetAndOtherItemIsAdded()
{
// arrange
var property = new Property<List<int>>();
// act
property.Value = new List<int> { 1 };
property.SetValueAsInitial();
property.Value = new List<int> { 2 };
// assert
Assert.IsTrue(property.HasChanged());
Assert.AreEqual(1, property.InitialValue.Count);
Assert.AreEqual(1, property.Value.Count);
}
示例4: HasChangedShouldBeTrueAfterInitialValueIsSetAndItemIsChanged
public void HasChangedShouldBeTrueAfterInitialValueIsSetAndItemIsChanged()
{
// arrange
var property = new Property<List<int>>();
// act
property.Value = new List<int> { 1 };
property.SetValueAsInitial();
property.Value[0] = 2;
// assert
Assert.True(property.HasChanged());
Assert.Equal(1, property.InitialValue.Count);
Assert.Equal(1, property.InitialValue[0]);
Assert.Equal(1, property.Value.Count);
Assert.Equal(2, property.Value[0]);
}
示例5: HasChangedShouldBeFalseAfterInitialValueIsSet
public void HasChangedShouldBeFalseAfterInitialValueIsSet()
{
// arrange
var property = new Property<List<int>>();
// act
property.Value = new List<int>();
property.SetValueAsInitial();
// assert
Assert.False(property.HasChanged());
Assert.Equal(0, property.InitialValue.Count);
Assert.Equal(0, property.Value.Count);
}
示例6: HasChangedShouldBeTrueAfterInitialValueIsSetAndItemIsChanged
public void HasChangedShouldBeTrueAfterInitialValueIsSetAndItemIsChanged()
{
// arrange
var property = new Property<Dictionary<string, string>>();
// act
property.Value = new Dictionary<string, string> { { "key", "value" } };
property.SetValueAsInitial();
property.Value["key"] = "another_value";
// assert
Assert.True(property.HasChanged());
Assert.Equal(1, property.InitialValue.Count);
Assert.Equal(1, property.Value.Count);
}
示例7: HasChangedShouldBeFalseAfterInitialValueIsSetAndSameItemIsAdded
public void HasChangedShouldBeFalseAfterInitialValueIsSetAndSameItemIsAdded()
{
// arrange
var property = new Property<Dictionary<string, string>>();
// act
property.Value = new Dictionary<string, string> { { "key", "value" } };
property.SetValueAsInitial();
property.Value = new Dictionary<string, string> { { "key", "value" } };
// assert
Assert.False(property.HasChanged());
Assert.Equal(1, property.InitialValue.Count);
Assert.Equal(1, property.Value.Count);
}
示例8: HasChangedShouldBeFalseAfterSetToNull
public void HasChangedShouldBeFalseAfterSetToNull()
{
// arrange
var property = new Property<Dictionary<string, string>>();
property.Value = new Dictionary<string, string>();
property.SetValueAsInitial();
// act
property.Value = null;
// assert
Assert.False(property.HasChanged());
}
示例9: HasChangedShouldBeFalseAfterInitialValueIsSet
public void HasChangedShouldBeFalseAfterInitialValueIsSet()
{
// arrange
var property = new Property<Dictionary<string, string>>();
// act
property.Value = new Dictionary<string, string>();
property.SetValueAsInitial();
// assert
Assert.False(property.HasChanged());
Assert.Equal(0, property.InitialValue.Count);
Assert.Equal(0, property.Value.Count);
}