コード例 #1
0
        public void SetOperationsTest()
        {
            var values = new[] { 15, 14, 89, 56, 8, 68, 17, 39, 31, 93, 78, 80, 87, 85, 57, 20, 6, 1 };

            var people     = new ObservableSet <Observable>(values.Select(x => new Observable(x)).ToList());
            var transfList = new DynamicTransformingReadOnlyObservableList <Observable, int>(people,
                                                                                             x => x.Subject);
            var copy = new TransformingReadOnlyObservableList <int, int>(transfList, x => x);

            Assert.AreEqual(people.Count, transfList.Count);
            Assert.IsTrue(new HashSet <int>(people.Select(x => x.Prop)).SetEquals(transfList));
            Assert.IsTrue(new HashSet <int>(people.Select(x => x.Prop)).SetEquals(copy));

            people.Add(new Observable(19));
            people.First().Prop = 82;
            people.Remove(people.Last());

            Assert.AreEqual(people.Count, transfList.Count);
            Assert.IsTrue(new HashSet <int>(people.Select(x => x.Prop)).SetEquals(transfList));
            Assert.IsTrue(new HashSet <int>(people.Select(x => x.Prop)).SetEquals(copy));
        }