public async Task AddRange2() { var list = new DictionaryReactiveCollectionSource <int, string>(); var notificationTask = list.ReactiveCollection.Changes .Skip(1) .FirstAsync() .ToTask(); var range = new[] { "A", "BB", "CCC" }; list.AddRange(range, x => x.Length); var notification = await notificationTask; notification.Action.Should().Be(NotifyCollectionChangedAction.Add); notification.NewItems.Should().HaveCount(3); notification.OldItems.Should().BeEmpty(); notification.Current.Should() .Contain(1, "A").And .Contain(2, "BB").And .Contain(3, "CCC"); }
public async Task AddRange1() { var list = new DictionaryReactiveCollectionSource<string, int>(); var notificationTask = list.ReactiveCollection.Changes .Skip(1) .FirstAsync() .ToTask(); var range = new Dictionary<string, int> { { "Key1", 1 }, { "Key2", 2 }, { "Key3", 3 } }; list.AddRange(range); var notification = await notificationTask; notification.Action.Should().Be(NotifyCollectionChangedAction.Add); notification.NewItems.Should().BeEquivalentTo(range); notification.OldItems.Should().BeEmpty(); notification.Current.Should().Equal(range); }
public async Task SetItems() { var list = new DictionaryReactiveCollectionSource <string, int>(DeterministicStringKeyComparer.Instance); var notificationTask = list.ReactiveCollection.Changes .Skip(2) .FirstAsync() .ToTask(); list.AddRange(new[] { new KeyValuePair <string, int>("Key1", 1), new KeyValuePair <string, int>("Key2", 2), new KeyValuePair <string, int>("Key3", 3) }); list.SetItems(new[] { new KeyValuePair <string, int>("Key1", 4), new KeyValuePair <string, int>("Key2", 5), new KeyValuePair <string, int>("Key3", 6) }); await Verify(notificationTask); }
public async Task AddRange1() { var list = new DictionaryReactiveCollectionSource <string, int>(); var notificationTask = list.ReactiveCollection.Changes .Skip(1) .FirstAsync() .ToTask(); var range = new Dictionary <string, int> { { "Key1", 1 }, { "Key2", 2 }, { "Key3", 3 } }; list.AddRange(range); var notification = await notificationTask; notification.Action.Should().Be(NotifyCollectionChangedAction.Add); notification.NewItems.Should().BeEquivalentTo(range); notification.OldItems.Should().BeEmpty(); notification.Current.Should().Equal(range); }
public async Task SetItems() { var list = new DictionaryReactiveCollectionSource <string, int>(); var notificationTask = list.ReactiveCollection.Changes .Skip(2) .FirstAsync() .ToTask(); list.AddRange(new[] { new KeyValuePair <string, int>("Key1", 1), new KeyValuePair <string, int>("Key2", 2), new KeyValuePair <string, int>("Key3", 3) }); list.SetItems(new[] { new KeyValuePair <string, int>("Key1", 4), new KeyValuePair <string, int>("Key2", 5), new KeyValuePair <string, int>("Key3", 6) }); var notification = await notificationTask; notification.Action.Should().Be(NotifyCollectionChangedAction.Reset); notification.Current.Should().Equal(new Dictionary <string, int> { { "Key1", 4 }, { "Key2", 5 }, { "Key3", 6 } }); }
public async Task SetItem() { var list = new DictionaryReactiveCollectionSource <string, int>(); var notificationTask = list.ReactiveCollection.Changes .Skip(2) .FirstAsync() .ToTask(); var range = new Dictionary <string, int> { { "Key1", 1 }, { "Key2", 2 }, { "Key3", 3 } }; list.AddRange(range); list.SetItem("Key2", 3); var notification = await notificationTask; notification.Action.Should().Be(NotifyCollectionChangedAction.Replace); notification.OldItems.Should().HaveCount(1); notification.OldItems.Should().Contain(new KeyValuePair <string, int>("Key2", 2)); notification.NewItems.Should().Contain(new KeyValuePair <string, int>("Key2", 3)); notification.Current.Should().Equal(new Dictionary <string, int> { { "Key1", 1 }, { "Key2", 3 }, { "Key3", 3 } }); }
public async Task RemoveRange() { var list = new DictionaryReactiveCollectionSource <string, int>(); var notificationsTask = list.ReactiveCollection.Changes .Skip(2) .Take(2) .ToArray() .ToTask(); list.AddRange(new[] { new KeyValuePair <string, int>("Key1", 1), new KeyValuePair <string, int>("Key2", 2), new KeyValuePair <string, int>("Key3", 3) }); list.RemoveRange(new[] { "Key1", "Key2" }); var notifications = await notificationsTask; notifications[0].Action.Should().Be(NotifyCollectionChangedAction.Remove); notifications[0].OldItems.Should().Equal(new KeyValuePair <string, int>("Key1", 1)); notifications[1].Action.Should().Be(NotifyCollectionChangedAction.Remove); notifications[1].OldItems.Should().Equal(new KeyValuePair <string, int>("Key2", 2)); notifications[1].Current.Should().Equal(new Dictionary <string, int> { { "Key3", 3 } }); }
public async Task SetItem() { var list = new DictionaryReactiveCollectionSource <string, int>(DeterministicStringKeyComparer.Instance); var notificationTask = list.ReactiveCollection.Changes .Skip(2) .FirstAsync() .ToTask(); list.AddRange(new Dictionary <string, int> { { "Key1", 1 }, { "Key2", 2 }, { "Key3", 3 } }); list.SetItem("Key2", 3); await Verify(notificationTask); }
public async Task AddRange2() { var list = new DictionaryReactiveCollectionSource <int, string>(); var notificationTask = list.ReactiveCollection.Changes .Skip(1) .FirstAsync() .ToTask(); var range = new[] { "A", "BB", "CCC" }; list.AddRange(range, x => x.Length); await Verify(notificationTask); }
public async Task RemoveRange() { var list = new DictionaryReactiveCollectionSource <string, int>(DeterministicStringKeyComparer.Instance); var notificationsTask = list.ReactiveCollection.Changes .Take(3) .ToArray() .ToTask(); list.AddRange(new[] { new KeyValuePair <string, int>("Key1", 1), new KeyValuePair <string, int>("Key2", 2), new KeyValuePair <string, int>("Key3", 3) }); list.RemoveRange(new[] { "Key1", "Key2" }); await Verify(notificationsTask); }
public async Task AddRange2() { var list = new DictionaryReactiveCollectionSource<int, string>(); var notificationTask = list.ReactiveCollection.Changes .Skip(1) .FirstAsync() .ToTask(); var range = new[] { "A", "BB", "CCC" }; list.AddRange(range, x => x.Length); var notification = await notificationTask; notification.Action.Should().Be(NotifyCollectionChangedAction.Add); notification.NewItems.Should().HaveCount(3); notification.OldItems.Should().BeEmpty(); notification.Current.Should() .Contain(1, "A").And .Contain(2, "BB").And .Contain(3, "CCC"); }
public async Task SetItems() { var list = new DictionaryReactiveCollectionSource<string, int>(); var notificationTask = list.ReactiveCollection.Changes .Skip(2) .FirstAsync() .ToTask(); list.AddRange(new[] { new KeyValuePair<string, int>("Key1", 1), new KeyValuePair<string, int>("Key2", 2), new KeyValuePair<string, int>("Key3", 3) }); list.SetItems(new[] { new KeyValuePair<string, int>("Key1", 4), new KeyValuePair<string, int>("Key2", 5), new KeyValuePair<string, int>("Key3", 6) }); var notification = await notificationTask; notification.Action.Should().Be(NotifyCollectionChangedAction.Reset); notification.Current.Should().Equal(new Dictionary<string, int> { { "Key1", 4 }, { "Key2", 5 }, { "Key3", 6 } }); }
public async Task SetItem() { var list = new DictionaryReactiveCollectionSource<string, int>(); var notificationTask = list.ReactiveCollection.Changes .Skip(2) .FirstAsync() .ToTask(); var range = new Dictionary<string, int> { { "Key1", 1 }, { "Key2", 2 }, { "Key3", 3 } }; list.AddRange(range); list.SetItem("Key2", 3); var notification = await notificationTask; notification.Action.Should().Be(NotifyCollectionChangedAction.Replace); notification.OldItems.Should().HaveCount(1); notification.OldItems.Should().Contain(new KeyValuePair<string, int>("Key2", 2)); notification.NewItems.Should().Contain(new KeyValuePair<string, int>("Key2", 3)); notification.Current.Should().Equal(new Dictionary<string, int> { { "Key1", 1 }, { "Key2", 3 }, { "Key3", 3 } }); }
public async Task RemoveRange() { var list = new DictionaryReactiveCollectionSource<string, int>(); var notificationsTask = list.ReactiveCollection.Changes .Skip(2) .Take(2) .ToArray() .ToTask(); list.AddRange(new[] { new KeyValuePair<string, int>("Key1", 1), new KeyValuePair<string, int>("Key2", 2), new KeyValuePair<string, int>("Key3", 3) }); list.RemoveRange(new[] { "Key1", "Key2" }); var notifications = await notificationsTask; notifications[0].Action.Should().Be(NotifyCollectionChangedAction.Remove); notifications[0].OldItems.Should().Equal(new KeyValuePair<string, int>("Key1", 1)); notifications[1].Action.Should().Be(NotifyCollectionChangedAction.Remove); notifications[1].OldItems.Should().Equal(new KeyValuePair<string, int>("Key2", 2)); notifications[1].Current.Should().Equal(new Dictionary<string, int> { { "Key3", 3 } }); }