Skip to content

Commit

Permalink
TestPropertiesView: Remove TestResultSubView and TestOutputSubView
Browse files Browse the repository at this point in the history
  • Loading branch information
rowo360 committed Feb 23, 2025
1 parent 82401c9 commit 26fbb72
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 250 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 0 additions & 34 deletions src/TestCentric/testcentric.gui/Dialogs/TestPropertiesDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ public void Display(TreeNode treeNode)

InitializeTestPackageSubView(_testNode);
InitializeTestPropertiesSubView(_testNode);
InitializeTestResultSubView(_testNode);
InitializeTestOutputSubView(_testNode);

AdjustSubViewHeights();
#endif

Expand Down Expand Up @@ -140,37 +137,6 @@ private void InitializeTestPropertiesSubView(TestNode testNode)
_view.TestPropertiesSubView.Visible = true;
}

private void InitializeTestResultSubView(TestNode testNode)
{
var resultNode = _model.GetResultForTest(testNode.Id);
var visible = resultNode != null;

if (visible)
{
_view.Outcome = resultNode.Outcome.ToString();
_view.ElapsedTime = resultNode.Duration.ToString("f3");
_view.AssertCount = resultNode.AssertCount.ToString();
_view.Assertions = GetAssertionResults(resultNode);

_visibleSubViews.Add(_view.TestResultSubView);
}

_view.TestResultSubView.Visible = visible;
}

private void InitializeTestOutputSubView(TestNode testNode)
{
var resultNode = _model.GetResultForTest(testNode.Id);
var visible = resultNode != null;

if (visible)
{
_view.Output = resultNode.Xml.SelectSingleNode("output")?.InnerText;
_visibleSubViews.Add(_view.TestOutputSubView);
}

_view.TestOutputSubView.Visible = visible;
}

private void AdjustSubViewHeights()
{
Expand Down
125 changes: 0 additions & 125 deletions src/TestCentric/testcentric.gui/Presenters/TestPropertiesPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
// ***********************************************************************

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;

namespace TestCentric.Gui.Presenters
{
Expand Down Expand Up @@ -65,8 +63,6 @@ private void DisplaySelectedItem()

InitializeTestPackageSubView(testNode);
InitializeTestPropertiesSubView(testNode);
InitializeTestResultSubView(testNode);
InitializeTestOutputSubView(testNode);

AdjustSubViewHeights();

Expand Down Expand Up @@ -118,33 +114,6 @@ private void InitializeTestPropertiesSubView(TestNode testNode)
_view.Properties = GetTestProperties(testNode);
}

private void InitializeTestResultSubView(TestNode testNode)
{
var resultNode = _model.GetResultForTest(testNode.Id);
var visible = resultNode != null;

if (visible)
{
_view.Outcome = resultNode.Outcome.ToString();
_view.ElapsedTime = resultNode.Duration.ToString("f3");
_view.AssertCount = resultNode.AssertCount.ToString();
_view.Assertions = GetAssertionResults(resultNode);
}

_view.TestResultSubView.InvokeIfRequired(() => _view.TestResultSubView.Visible = visible);
}

private void InitializeTestOutputSubView(TestNode testNode)
{
var resultNode = _model.GetResultForTest(testNode.Id);
var visible = resultNode != null;

if (visible)
_view.Output = resultNode.Xml.SelectSingleNode("output")?.InnerText;

_view.TestOutputSubView.InvokeIfRequired(() => _view.TestOutputSubView.Visible = visible);
}

private void AdjustSubViewHeights()
{
var visibleSubViews = _view.SubViews.Where(x => x.Visible);
Expand Down Expand Up @@ -221,100 +190,6 @@ private string GetTestProperties(TestNode testNode)
return sb.ToString();
}

// Sometimes, the message may have leading blank lines and/or
// may be longer than Windows really wants to display.
private string TrimMessage(string message)
{
if (message != null)
{
if (message.Length > 64000)
message = message.Substring(0, 64000);

int start = 0;
for (int i = 0; i < message.Length; i++)
{
switch (message[i])
{
case ' ':
case '\t':
break;
case '\r':
case '\n':
start = i + 1;
break;

default:
return start == 0 ? message : message.Substring(start);
}
}
}

return message;
}

private string GetAssertionResults(ResultNode resultNode)
{
StringBuilder sb;
var assertionResults = resultNode.Assertions;

// If there were no actual assertionresult entries, we fake
// one if there is a message to display
if (assertionResults.Count == 0)
{
if (resultNode.Outcome.Status == TestStatus.Failed)
{
string status = resultNode.Outcome.Label ?? "Failed";
XmlNode failure = resultNode.Xml.SelectSingleNode("failure");
if (failure != null)
assertionResults.Add(new AssertionResult(failure, status));
}
else
{
string status = resultNode.Outcome.Label ?? "Skipped";
XmlNode reason = resultNode.Xml.SelectSingleNode("reason");
if (reason != null)
assertionResults.Add(new AssertionResult(reason, status));
}
}

sb = new StringBuilder();
int index = 0;
foreach (var assertion in assertionResults)
{
sb.AppendLine($"{++index}) {assertion.Status.ToUpper()} {assertion.Message}");
if (assertion.StackTrace != null)
sb.AppendLine(AdjustStackTrace(assertion.StackTrace));

}

return sb.ToString();
}

// Some versions of the framework return the stacktrace
// without leading spaces, so we add them if needed.
// TODO: Make sure this is valid across various cultures.
private const string LEADING_SPACES = " ";

private static string AdjustStackTrace(string stackTrace)
{
// Check if no adjustment needed. We assume that all
// lines start the same - either with or without spaces.
if (stackTrace.StartsWith(LEADING_SPACES))
return stackTrace;

var sr = new StringReader(stackTrace);
var sb = new StringBuilder();
string line = sr.ReadLine();
while (line != null)
{
sb.Append(LEADING_SPACES);
sb.AppendLine(line);
line = sr.ReadLine();
}

return sb.ToString();
}

#endregion
}
}
8 changes: 0 additions & 8 deletions src/TestCentric/testcentric.gui/Views/ITestPropertiesVIew.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,10 @@ public interface ITestPropertiesView : IView
string SkipReason { get; set; }
bool DisplayHiddenProperties { get; }
string Properties { get; set; }
string Outcome { get; set; }
string ElapsedTime { get; set; }
string AssertCount { get; set; }
string Assertions { get; set; }
string Output { get; set; }
string PackageSettings { get; set; }

TestPackageSubView TestPackageSubView { get; }
TestPropertiesSubView TestPropertiesSubView { get; }
TestResultSubView TestResultSubView { get; }
TestOutputSubView TestOutputSubView { get; }

TestPropertiesView.SubView[] SubViews { get; }
}
}
5 changes: 0 additions & 5 deletions src/TestCentric/testcentric.gui/Views/TestCentricMainView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -942,20 +942,15 @@ private void InitializeComponent()
//
// propertiesView
//
this.propertiesView.AssertCount = "";
this.propertiesView.Assertions = "";
this.propertiesView.AutoScroll = true;
this.propertiesView.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.propertiesView.Categories = "";
this.propertiesView.Description = "";
this.propertiesView.Dock = System.Windows.Forms.DockStyle.Fill;
this.propertiesView.ElapsedTime = "";
this.propertiesView.FullName = "";
this.propertiesView.Header = "";
this.propertiesView.Location = new System.Drawing.Point(0, 0);
this.propertiesView.Name = "propertiesView";
this.propertiesView.Outcome = "";
this.propertiesView.Output = "";
this.propertiesView.PackageSettings = "";
this.propertiesView.Properties = "";
this.propertiesView.RunState = "";
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 1 addition & 37 deletions src/TestCentric/testcentric.gui/Views/TestPropertiesView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ private void FlowLayoutPanel1_Layout(object sender, LayoutEventArgs e)
header.Width = subViewWidth;
testPackageSubView.Width = subViewWidth;
testPropertiesSubView.Width = subViewWidth;
testResultSubView.Width = subViewWidth;
testOutputSubView.Width = subViewWidth;
}

public int ClientHeight => ClientRectangle.Height - TestPackageSubView.Top - 40; // Value of 40 allows for non-client areas and spacing
Expand All @@ -51,11 +49,7 @@ public string Header

public TestPropertiesSubView TestPropertiesSubView => testPropertiesSubView;

public TestResultSubView TestResultSubView => testResultSubView;

public TestOutputSubView TestOutputSubView => testOutputSubView;

public SubView[] SubViews => new SubView[] { TestPackageSubView, TestPropertiesSubView, TestResultSubView, TestOutputSubView };
public SubView[] SubViews => new SubView[] { TestPackageSubView, TestPropertiesSubView };

public string TestType
{
Expand Down Expand Up @@ -110,36 +104,6 @@ public string Properties
set { testPropertiesSubView.Properties = value; }
}

public string Outcome
{
get { return testResultSubView.Outcome; }
set { testResultSubView.Outcome = value; }
}

public string ElapsedTime
{
get { return testResultSubView.ElapsedTime; }
set { testResultSubView.ElapsedTime = value; }
}

public string AssertCount
{
get { return testResultSubView.AssertCount; }
set { testResultSubView.AssertCount = value; }
}

public string Assertions
{
get { return testResultSubView.Assertions; }
set { testResultSubView.Assertions = value; }
}

public string Output
{
get { return testOutputSubView.Output; }
set { testOutputSubView.Output = value; }
}

public string PackageSettings
{
get { return testPackageSubView.PackageSettings; }
Expand Down

0 comments on commit 26fbb72

Please sign in to comment.