Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
hadashiA committed Feb 15, 2024
1 parent 76de096 commit ba5b572
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ internal class NotifyCollectionChangedSynchronizedView<T, TView> :
static readonly PropertyChangedEventArgs CountPropertyChangedEventArgs = new("Count");

readonly ISynchronizedView<T, TView> parent;
readonly ISynchronizedViewFilter<T, TView> currentFilter;

public NotifyCollectionChangedSynchronizedView(ISynchronizedView<T, TView> parent)
{
this.parent = parent;
currentFilter = parent.CurrentFilter;
parent.AttachFilter(this);
}

Expand Down Expand Up @@ -52,13 +54,13 @@ public IEnumerator<TView> GetEnumerator()

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<T> eventArgs)
{
parent.CurrentFilter.OnCollectionChanged(changedKind, value, view, in eventArgs);
currentFilter.OnCollectionChanged(changedKind, value, view, in eventArgs);

switch (changedKind)
{
Expand Down
1 change: 0 additions & 1 deletion src/ObservableCollections/ObservableList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public int Count

public event NotifyCollectionChangedEventHandler<T>? CollectionChanged;


public void Add(T item)
{
lock (SyncRoot)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ public void ToNotifyCollectionChanged()
var list = new ObservableList<int>();

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();
Expand Down

0 comments on commit ba5b572

Please sign in to comment.