本文整理汇总了C#中ObservableDictionary.ShouldRaise方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableDictionary.ShouldRaise方法的具体用法?C# ObservableDictionary.ShouldRaise怎么用?C# ObservableDictionary.ShouldRaise使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObservableDictionary
的用法示例。
在下文中一共展示了ObservableDictionary.ShouldRaise方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveRangeRaisesPropertyChangedEventForItemIndexerAndCount
public void RemoveRangeRaisesPropertyChangedEventForItemIndexerAndCount()
{
// given
var items = new List<KeyValuePair<int, string>>()
{
new KeyValuePair<int, string>(1, "One"),
new KeyValuePair<int, string>(2, "Two"),
new KeyValuePair<int, string>(3, "Three"),
};
using (var observableDictionary = new ObservableDictionary<int, string>(items))
{
observableDictionary.ThresholdAmountWhenChangesAreNotifiedAsReset = 0;
observableDictionary.MonitorEvents();
// when
observableDictionary.RemoveRange(items);
// then
observableDictionary
.ShouldRaise(nameof(observableDictionary.PropertyChanged))
.WithSender(observableDictionary)
.WithArgs<PropertyChangedEventArgs>(args => args.PropertyName == "Item[]");
observableDictionary
.ShouldRaise(nameof(observableDictionary.PropertyChanged))
.WithSender(observableDictionary)
.WithArgs<PropertyChangedEventArgs>(args => args.PropertyName == nameof(observableDictionary.Count));
}
}
示例2: RemoveRaisesPropertyChangedEventForItemIndexerAndCount
public void RemoveRaisesPropertyChangedEventForItemIndexerAndCount()
{
// given
using (var observableDictionary = new ObservableDictionary<int, string>())
{
observableDictionary.Add(1, "One");
observableDictionary.MonitorEvents();
// when
observableDictionary.Remove(1);
// then
observableDictionary
.ShouldRaise(nameof(observableDictionary.PropertyChanged))
.WithSender(observableDictionary)
.WithArgs<PropertyChangedEventArgs>(args => args.PropertyName == "Item[]");
observableDictionary
.ShouldRaise(nameof(observableDictionary.PropertyChanged))
.WithSender(observableDictionary)
.WithArgs<PropertyChangedEventArgs>(args => args.PropertyName == nameof(observableDictionary.Count));
}
}
示例3: using
public void RemoveRangeRaisesPropertyChangedEventForItemIndexerAndCountOnlyOnceWhenThresholdAmountWhenItemChangesAreNotifiedAsResetIsSetAccordingly()
{
// given
var items = new List<KeyValuePair<int, string>>()
{
new KeyValuePair<int, string>(1, "One"),
new KeyValuePair<int, string>(2, "Two"),
new KeyValuePair<int, string>(3, "Three"),
};
using (var observableDictionary = new ObservableDictionary<int, string>(items))
{
observableDictionary.ThresholdAmountWhenChangesAreNotifiedAsReset = 0;
observableDictionary.MonitorEvents();
// when
observableDictionary.RemoveRange(items);
// then
observableDictionary
.ShouldRaise(nameof(observableDictionary.PropertyChanged))
.WithSender(observableDictionary)
.WithArgs<PropertyChangedEventArgs>(args => args.PropertyName == "Item[]")
.Should().HaveCount(1); // ToDo: re-enable test if/when https://github.com/dennisdoomen/fluentassertions/issues/337 has been fixed
observableDictionary
.ShouldRaise(nameof(observableDictionary.PropertyChanged))
.WithSender(observableDictionary)
.WithArgs<PropertyChangedEventArgs>(args => args.PropertyName == nameof(observableDictionary.Count))
.Should().HaveCount(1); // ToDo: re-enable test if/when https://github.com/dennisdoomen/fluentassertions/issues/337 has been fixed
}
}