2021-08-06 20:08:12 +09:00
|
|
|
using FluentAssertions;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.ObjectModel;
|
2024-02-22 12:47:19 +09:00
|
|
|
using System.Collections.Specialized;
|
2021-08-06 20:08:12 +09:00
|
|
|
using System.Linq;
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
namespace ObservableCollections.Tests
|
|
|
|
{
|
|
|
|
public class ObservableDictionaryTest
|
|
|
|
{
|
|
|
|
[Fact]
|
|
|
|
public void View()
|
|
|
|
{
|
|
|
|
var dict = new ObservableDictionary<int, int>();
|
|
|
|
var view = dict.CreateView(x => new ViewContainer<int>(x.Value));
|
|
|
|
|
|
|
|
dict.Add(10, -10); // 0
|
|
|
|
dict.Add(50, -50); // 1
|
|
|
|
dict.Add(30, -30); // 2
|
|
|
|
dict.Add(20, -20); // 3
|
|
|
|
dict.Add(40, -40); // 4
|
|
|
|
|
|
|
|
void Equal(params int[] expected)
|
|
|
|
{
|
|
|
|
dict.Select(x => x.Value).OrderByDescending(x => x).Should().Equal(expected);
|
|
|
|
}
|
|
|
|
|
|
|
|
Equal(-10, -20, -30, -40, -50);
|
|
|
|
|
|
|
|
dict[99] = -100;
|
|
|
|
Equal(-10, -20, -30, -40, -50, -100);
|
|
|
|
|
|
|
|
dict[10] = -5;
|
|
|
|
Equal(-5, -20, -30, -40, -50, -100);
|
|
|
|
|
|
|
|
dict.Remove(20);
|
|
|
|
Equal(-5, -30, -40, -50, -100);
|
|
|
|
|
|
|
|
dict.Clear();
|
|
|
|
Equal(new int[0]);
|
|
|
|
}
|
|
|
|
|
2024-02-01 19:06:45 +09:00
|
|
|
|
2021-08-06 20:08:12 +09:00
|
|
|
}
|
|
|
|
}
|