Exemplo n.º 1
0
        public void TestValidationPerformanceOfSimpleList()
        {
            var itemCount   = 1;
            var itemsSource = new List <SimpleListItemVM>(itemCount);

            PerformanceTest.MeasureCodeBlock(
                "Create and add item VMs to source list",
                () => {
                for (int i = 0; i < itemCount; i++)
                {
                    itemsSource.Add(new SimpleListItemVM()
                    {
                        StringProperty = "Item " + i
                    });
                }
            }
                );

            SimpleListVM list = null;

            PerformanceTest.MeasureCodeBlock(
                "Create and set source of list VM",
                () => {
                list             = new SimpleListVM();
                list.ItemsSource = itemsSource;
            }
                );

            PerformanceTest.MeasureCodeBlock(
                "First access of list",
                () => {
                list.Load(x => x.Items);
            }
                );

            PerformanceTest.MeasureCodeBlock(
                "Revalidate AllDescendants",
                () => {
                list.Revalidate(ValidationScope.SelfAndAllDescendants);
            }
                );

            PerformanceTest.MeasureCodeBlock(
                "Revalidate AllDescendants second time",
                () => {
                list.Revalidate(ValidationScope.SelfAndAllDescendants);
            }
                );
        }