예제 #1
0
        public void StoppingTimerStopsTimer()
        {
            var analyzer = new AnalyzeInvokeCountAnalyzer();
            VisualTreeWalker      walker = null;
            VisualTreeWalkerTimer timer  = null;

            RunOnUIThread.Execute(() =>
            {
                walker = new VisualTreeWalker(new Button(), analyzer);
                timer  = new VisualTreeWalkerTimer(walker, 10);
                timer.Start();
            });
            RunOnUIThread.WaitMilliSeconds(300);
            Assert.IsTrue(analyzer.AnalyzeCount >= 1);

            var oldCount = 0;

            RunOnUIThread.Execute(() =>
            {
                timer.Stop();
                Logger.LogMessage("Analyzer count before stopping: " + analyzer.AnalyzeCount);
                oldCount = analyzer.AnalyzeCount;
            });

            RunOnUIThread.WaitMilliSeconds(400);
            Logger.LogMessage("Analyzer count after stopping: " + analyzer.AnalyzeCount);
            Assert.IsTrue(analyzer.AnalyzeCount == oldCount);
        }
예제 #2
0
        public void ScansMultipleTimes()
        {
            var analyzer = new AnalyzeInvokeCountAnalyzer();
            VisualTreeWalker      walker = null;
            VisualTreeWalkerTimer timer  = null;

            RunOnUIThread.Execute(() =>
            {
                walker = new VisualTreeWalker(new Button(), analyzer);
                timer  = new VisualTreeWalkerTimer(walker, 10);
                timer.Start();
            });

            RunOnUIThread.WaitMilliSeconds(500);

            Logger.LogMessage("Analyzer count: " + analyzer.AnalyzeCount);
            Assert.IsTrue(analyzer.AnalyzeCount >= 2);
        }