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