예제 #1
0
 /// <summary>
 /// Compares the current result of the <see cref="TestCase"/> with the
 /// expected result.
 /// </summary>
 /// <param name="testCase">The <see cref="TestCase"/> to compare.</param>
 public void Compare(TestCase testCase)
 {
     // Compare the result
     if (testCase.ExpectedResult != null)
     {
         ObjectTreeModelCreator  creator          = new ObjectTreeModelCreator();
         ObjectField             currentTreeRoot  = creator.CreateModel(testCase.CurrentResult);
         ObjectField             expectedTreeRoot = creator.CreateModel(testCase.ExpectedResult);
         ObjectTreeModelComparer comparer         = new ObjectTreeModelComparer();
         comparer.CompareFields += Comparer_CompareFields;
         comparer.Compare(expectedTreeRoot, currentTreeRoot);
         testCase.Percent = comparer.GetResult(expectedTreeRoot).Percent;
         testCase.State   = testCase.Percent >= 1.0 ? TestCaseState.Success : TestCaseState.Fail;
     }
 }
        // ========================================================================
        // Fields

        #region === Fields

        #endregion

        // ========================================================================
        // Con- / Destructors

        #region === Con- / Destructors

        /// <summary>
        /// Initializes a new instance of <see cref="ObjectComparePanel"/>.
        /// </summary>
        public ObjectComparePanel()
        {
            InitializeComponent();

            toolStripButtonSynchronizeTrees.CheckState  = Settings.Default.ObjectComparePanelSynchronizeTrees;
            toolStripButtonAutoResizeColumns.CheckState = Settings.Default.ObjectComparePanelAutoResizeColumnsCheckState;
            toolStripButtonAutoResizeColumns_Click(null, null);

            TreeColumn treeColumnResult  = new TreeColumn("Result", Resources.Equal.Width);
            NodeIcon   nodeControlResult = new NodeIcon {
                VirtualMode = true, ParentColumn = treeColumnResult, VerticalAlign = VerticalAlignment.Center
            };

            treeColumnResult.Width        += 2 * nodeControlResult.LeftMargin;
            nodeControlResult.ValueNeeded += nodeControlResult_ValueNeeded;
            expectedObjectTree.AddExtraColumn(treeColumnResult, nodeControlResult);

            TreeColumn treeColumnPercent = new TreeColumn("Percent", 50);
            ComparePercentageNodeControl nodeControlPercent = new ComparePercentageNodeControl {
                VirtualMode = true, ParentColumn = treeColumnPercent
            };

            nodeControlPercent.ValueNeeded += nodeControlPercent_ValueNeeded;
            expectedObjectTree.AddExtraColumn(treeColumnPercent, nodeControlPercent);

            TreeColumn treeColumnResultCurrent  = new TreeColumn("Result", Resources.Equal.Width);
            NodeIcon   nodeControlResultCurrent = new NodeIcon {
                VirtualMode = true, ParentColumn = treeColumnResultCurrent, VerticalAlign = VerticalAlignment.Center
            };

            treeColumnResultCurrent.Width        += 2 * nodeControlResult.LeftMargin;
            nodeControlResultCurrent.ValueNeeded += nodeControlResult_ValueNeeded;
            currentObjectTree.AddExtraColumn(2, treeColumnResultCurrent, nodeControlResultCurrent);

            TreeColumn treeColumnPercentCurrent = new TreeColumn("Percent", 50);
            ComparePercentageNodeControl nodeControlPercentCurrent = new ComparePercentageNodeControl {
                VirtualMode = true, ParentColumn = treeColumnPercentCurrent
            };

            nodeControlPercentCurrent.ValueNeeded += nodeControlPercent_ValueNeeded;
            currentObjectTree.AddExtraColumn(3, treeColumnPercentCurrent, nodeControlPercentCurrent);

            Comparer = new ObjectTreeModelComparer();
            Comparer.CompareFields += TestCaseRunner.Instance.Comparer_CompareFields;
        }