Esempio n. 1
0
        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 }
            });
        }
Esempio n. 2
0
        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 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 }
            });
        }