예제 #1
0
            public void DumpAndVerifyVisualTree(UIElement root, string verificationFileNamePrefix, string messageOnError = null)
            {
                VisualTreeLog.LogDebugInfo("DumpVisualTreeAndCompareWithverification with verificationFileNamePrefix " + verificationFileNamePrefix);

                string expectedContent = "";
                string content         = DumpVisualTree(root, _translator, _filter, _logger);

                VerificationFileStorage storage        = new VerificationFileStorage(!_shouldLogVerificationFile, verificationFileNamePrefix);
                string bestMatchedVerificationFileName = storage.BestMatchedVerificationFileName;
                string expectedVerificationFileName    = storage.ExpectedVerificationFileName;

                VisualTreeLog.LogDebugInfo("Target verification file: " + expectedVerificationFileName);
                VisualTreeLog.LogDebugInfo("Best matched verification file: " + bestMatchedVerificationFileName);

                if (!string.IsNullOrEmpty(bestMatchedVerificationFileName))
                {
                    expectedContent = VerificationFileStorage.GetVerificationFileContent(bestMatchedVerificationFileName);
                }

                string result = new VisualTreeOutputCompare(content, expectedContent).ToString();

                if (!string.IsNullOrEmpty(result))
                {
                    storage.LogVerificationFile(expectedVerificationFileName, content);
                    storage.LogVerificationFile(expectedVerificationFileName + ".orig", expectedContent);

                    if (!string.IsNullOrEmpty(messageOnError))
                    {
                        _testResult.AppendLine(messageOnError);
                        _testResult.AppendLine(string.Format("{0}.xml and {0}.orig.xaml is logged", expectedVerificationFileName));
                    }
                    _testResult.AppendLine(result);
                }
            }