From ba5b572d2e6862b7a67d8e60b604b872f24df4c1 Mon Sep 17 00:00:00 2001 From: hadashiA Date: Thu, 15 Feb 2024 14:36:55 +0900 Subject: [PATCH] Fix test --- .../NotifyCollectionChangedSynchronizedView.cs | 10 ++++++---- src/ObservableCollections/ObservableList.cs | 1 - .../ToNotifyCollectionChangedTest.cs | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/ObservableCollections/Internal/NotifyCollectionChangedSynchronizedView.cs b/src/ObservableCollections/Internal/NotifyCollectionChangedSynchronizedView.cs index eaf1cb4..46234db 100644 --- a/src/ObservableCollections/Internal/NotifyCollectionChangedSynchronizedView.cs +++ b/src/ObservableCollections/Internal/NotifyCollectionChangedSynchronizedView.cs @@ -13,10 +13,12 @@ namespace ObservableCollections.Internal static readonly PropertyChangedEventArgs CountPropertyChangedEventArgs = new("Count"); readonly ISynchronizedView parent; + readonly ISynchronizedViewFilter currentFilter; public NotifyCollectionChangedSynchronizedView(ISynchronizedView parent) { this.parent = parent; + currentFilter = parent.CurrentFilter; parent.AttachFilter(this); } @@ -52,13 +54,13 @@ namespace ObservableCollections.Internal IEnumerator IEnumerable.GetEnumerator() => parent.GetEnumerator(); - public bool IsMatch(T value, TView view) => parent.CurrentFilter.IsMatch(value, view); - public void WhenTrue(T value, TView view) => parent.CurrentFilter.WhenTrue(value, view); - public void WhenFalse(T value, TView view) => parent.CurrentFilter.WhenFalse(value, view); + public bool IsMatch(T value, TView view) => currentFilter.IsMatch(value, view); + public void WhenTrue(T value, TView view) => currentFilter.WhenTrue(value, view); + public void WhenFalse(T value, TView view) => currentFilter.WhenFalse(value, view); public void OnCollectionChanged(ChangedKind changedKind, T value, TView view, in NotifyCollectionChangedEventArgs eventArgs) { - parent.CurrentFilter.OnCollectionChanged(changedKind, value, view, in eventArgs); + currentFilter.OnCollectionChanged(changedKind, value, view, in eventArgs); switch (changedKind) { diff --git a/src/ObservableCollections/ObservableList.cs b/src/ObservableCollections/ObservableList.cs index cc024c4..dc33723 100644 --- a/src/ObservableCollections/ObservableList.cs +++ b/src/ObservableCollections/ObservableList.cs @@ -62,7 +62,6 @@ namespace ObservableCollections public event NotifyCollectionChangedEventHandler? CollectionChanged; - public void Add(T item) { lock (SyncRoot) diff --git a/tests/ObservableCollections.Tests/ToNotifyCollectionChangedTest.cs b/tests/ObservableCollections.Tests/ToNotifyCollectionChangedTest.cs index 746edb6..106b6ec 100644 --- a/tests/ObservableCollections.Tests/ToNotifyCollectionChangedTest.cs +++ b/tests/ObservableCollections.Tests/ToNotifyCollectionChangedTest.cs @@ -8,13 +8,13 @@ public class ToNotifyCollectionChangedTest var list = new ObservableList(); list.Add(10); - list.Add(50); + list.Add(20); list.Add(30); var notify = list.CreateView(x => $"${x}").ToNotifyCollectionChanged(); - list.Add(20); list.Add(40); + list.Add(50); using var e = notify.GetEnumerator(); e.MoveNext().Should().BeTrue();