コード例 #1
0
        public void Simple()
        {
            var data = new List <Task>
            {
                new Task {
                    Title = "task1"
                }
            };
            var groupBuilder = new GroupBuilder <Task>(
                p => p.Title,
                p => p.Title,
                (g1, g2) => g1.Title.CompareTo(g2.Title),
                (p1, p2) => p1.Title.CompareTo(p2.Title));

            var collection = new SmartCollection <Task>(data, groupBuilder, t => !t.Completed.HasValue);

            Assert.AreEqual(1, collection.Items.Count);
            Assert.AreEqual(1, collection.Items[0].Count);
            Assert.AreEqual("task1", collection.Items[0][0].Title);

            data[0].IsCompleted = true;
            collection.InvalidateItem(data[0]);

            Assert.AreEqual(0, collection.Items.Count);

            data[0].IsCompleted = false;
            collection.InvalidateItem(data[0]);

            Assert.AreEqual(1, collection.Items.Count);
            Assert.AreEqual(1, collection.Items[0].Count);
            Assert.AreEqual("task1", collection.Items[0][0].Title);
        }