Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .reviewmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ reviews:
- id: TestResults-Model
title: Review of TestResults Model
paths:
- "docs/reqstream/model.yaml"
- "docs/design/model.md"
- "src/DemaConsulting.TestResults/*.cs"
- "test/DemaConsulting.TestResults.Tests/*.cs"
- "!**/obj/**"
- "docs/design/model.md"
- "docs/reqstream/model.yaml"

- id: TestResults-Serialization
title: Review of TestResults Serialization
paths:
- "docs/reqstream/serialization.yaml"
- "docs/design/serialization.md"
- "src/DemaConsulting.TestResults/IO/**/*.cs"
- "test/DemaConsulting.TestResults.Tests/IO/**/*.cs"
- "!**/obj/**"
- "docs/design/serialization.md"
- "docs/reqstream/serialization.yaml"
3 changes: 2 additions & 1 deletion docs/design/model.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ It is deliberately free of serialization concerns — it knows nothing about TRX
XML — so that it can serve as a neutral interchange format between different serializers
and consumers.

The model consists of three types:
The model consists of four types:

- `TestOutcome` — an enumeration of all possible test execution outcomes
- `TestOutcomeExtensions` — extension methods that classify a `TestOutcome` into logical categories
- `TestResult` — a single test case result, including timing, output, and error information
- `TestResults` — a collection of `TestResult` objects representing a complete test run

Expand Down
4 changes: 2 additions & 2 deletions docs/reqstream/model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ sections:
pass or fail result. This status is important for test frameworks that support
inconclusive results and helps distinguish ambiguous test executions from failures.
tests:
- TestOutcome_IsExecuted_InconclusiveOutcome_ReturnsTrue
- TestOutcome_IsExecuted_AllOutcomes_ReturnsExpectedResult
- TrxExampleTests_Deserialize_Example1Trx_ReturnsAllTestResults

- id: TestResults-Mdl-AbortedOutcome
Expand All @@ -82,7 +82,7 @@ sections:
started. This status is important for test frameworks that support asynchronous or
deferred test execution and helps track test execution state.
tests:
- TestOutcome_IsExecuted_InconclusiveOutcome_ReturnsTrue
- TestOutcome_IsExecuted_AllOutcomes_ReturnsExpectedResult
- TestOutcome_IsPassed_PassedOutcome_ReturnsTrue
- TrxExampleTests_Deserialize_Example1Trx_ReturnsAllTestResults

Expand Down
2 changes: 1 addition & 1 deletion src/DemaConsulting.TestResults/TestOutcome.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
namespace DemaConsulting.TestResults;

/// <summary>
/// TestOutcome enum
/// Defines the possible outcomes for a test case execution.
/// </summary>
public enum TestOutcome
{
Expand Down
2 changes: 1 addition & 1 deletion src/DemaConsulting.TestResults/TestResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
namespace DemaConsulting.TestResults;

/// <summary>
/// TestResult class
/// Represents the result of a single test case execution.
/// </summary>
public sealed class TestResult
{
Expand Down
2 changes: 1 addition & 1 deletion src/DemaConsulting.TestResults/TestResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
namespace DemaConsulting.TestResults;

/// <summary>
/// TestResults class
/// Represents a collection of test results for a complete test run.
/// </summary>
public sealed class TestResults
{
Expand Down
2 changes: 1 addition & 1 deletion test/DemaConsulting.TestResults.Tests/TestOutcomeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void TestOutcome_IsFailed_FailedOutcome_ReturnsTrue()
/// Test the IsExecuted method for all outcomes
/// </summary>
[TestMethod]
public void TestOutcome_IsExecuted_InconclusiveOutcome_ReturnsTrue()
public void TestOutcome_IsExecuted_AllOutcomes_ReturnsExpectedResult()
{
Assert.IsTrue(TestOutcome.Error.IsExecuted());
Assert.IsTrue(TestOutcome.Failed.IsExecuted());
Expand Down
245 changes: 245 additions & 0 deletions test/DemaConsulting.TestResults.Tests/TestResultTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
// Copyright(c) 2025 DEMA Consulting
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace DemaConsulting.TestResults.Tests;

/// <summary>
/// Tests for the default property values of <see cref="TestResult" />
/// </summary>
[TestClass]
public class TestResultTests
{
/// <summary>
/// Tests that <see cref="TestResult.TestId" /> defaults to a non-empty GUID
/// </summary>
[TestMethod]
public void TestResult_TestId_Default_IsNotEmpty()
{
// Arrange - create a new TestResult with default property values

// Act
var result = new TestResult();

// Assert - TestId should be auto-generated and not the empty GUID
Assert.AreNotEqual(Guid.Empty, result.TestId);
}

/// <summary>
/// Tests that two separate <see cref="TestResult" /> instances have different <see cref="TestResult.TestId" /> values,
/// proving that each instance generates its own unique identifier
/// </summary>
[TestMethod]
public void TestResult_TestId_TwoInstances_AreUnique()
{
// Arrange - create two independent TestResult instances

// Act
var result1 = new TestResult();
var result2 = new TestResult();

// Assert - each instance should have a distinct TestId
Assert.AreNotEqual(result1.TestId, result2.TestId);
}

/// <summary>
/// Tests that <see cref="TestResult.ExecutionId" /> defaults to a non-empty GUID
/// </summary>
[TestMethod]
public void TestResult_ExecutionId_Default_IsNotEmpty()
{
// Arrange - create a new TestResult with default property values

// Act
var result = new TestResult();

// Assert - ExecutionId should be auto-generated and not the empty GUID
Assert.AreNotEqual(Guid.Empty, result.ExecutionId);
}

/// <summary>
/// Tests that two separate <see cref="TestResult" /> instances have different
/// <see cref="TestResult.ExecutionId" /> values, proving that each instance generates its own unique identifier
/// </summary>
[TestMethod]
public void TestResult_ExecutionId_TwoInstances_AreUnique()
{
// Arrange - create two independent TestResult instances

// Act
var result1 = new TestResult();
var result2 = new TestResult();

// Assert - each instance should have a distinct ExecutionId
Assert.AreNotEqual(result1.ExecutionId, result2.ExecutionId);
}

/// <summary>
/// Tests that <see cref="TestResult.Name" /> defaults to an empty string
/// </summary>
[TestMethod]
public void TestResult_Name_Default_IsEmpty()
{
// Arrange - create a new TestResult with default property values

// Act
var result = new TestResult();

// Assert - Name should default to string.Empty
Assert.AreEqual(string.Empty, result.Name);
}

/// <summary>
/// Tests that <see cref="TestResult.CodeBase" /> defaults to an empty string
/// </summary>
[TestMethod]
public void TestResult_CodeBase_Default_IsEmpty()
{
// Arrange - create a new TestResult with default property values

// Act
var result = new TestResult();

// Assert - CodeBase should default to string.Empty
Assert.AreEqual(string.Empty, result.CodeBase);
}

/// <summary>
/// Tests that <see cref="TestResult.ClassName" /> defaults to an empty string
/// </summary>
[TestMethod]
public void TestResult_ClassName_Default_IsEmpty()
{
// Arrange - create a new TestResult with default property values

// Act
var result = new TestResult();

// Assert - ClassName should default to string.Empty
Assert.AreEqual(string.Empty, result.ClassName);
}

/// <summary>
/// Tests that <see cref="TestResult.ComputerName" /> defaults to the current machine name
/// </summary>
[TestMethod]
public void TestResult_ComputerName_Default_IsEnvironmentMachineName()
{
// Arrange - record the expected machine name before construction
var expectedComputerName = Environment.MachineName;

// Act
var result = new TestResult();

// Assert - ComputerName should match the environment's machine name
Assert.AreEqual(expectedComputerName, result.ComputerName);
}

/// <summary>
/// Tests that <see cref="TestResult.Duration" /> defaults to <see cref="TimeSpan.Zero" />
/// </summary>
[TestMethod]
public void TestResult_Duration_Default_IsZero()
{
// Arrange - create a new TestResult with default property values

// Act
var result = new TestResult();

// Assert - Duration should default to TimeSpan.Zero
Assert.AreEqual(TimeSpan.Zero, result.Duration);
}

/// <summary>
/// Tests that <see cref="TestResult.SystemOutput" /> defaults to an empty string
/// </summary>
[TestMethod]
public void TestResult_SystemOutput_Default_IsEmpty()
{
// Arrange - create a new TestResult with default property values

// Act
var result = new TestResult();

// Assert - SystemOutput should default to string.Empty
Assert.AreEqual(string.Empty, result.SystemOutput);
}

/// <summary>
/// Tests that <see cref="TestResult.SystemError" /> defaults to an empty string
/// </summary>
[TestMethod]
public void TestResult_SystemError_Default_IsEmpty()
{
// Arrange - create a new TestResult with default property values

// Act
var result = new TestResult();

// Assert - SystemError should default to string.Empty
Assert.AreEqual(string.Empty, result.SystemError);
}

/// <summary>
/// Tests that <see cref="TestResult.Outcome" /> defaults to <see cref="TestOutcome.NotExecuted" />
/// </summary>
[TestMethod]
public void TestResult_Outcome_Default_IsNotExecuted()
{
// Arrange - create a new TestResult with default property values

// Act
var result = new TestResult();

// Assert - Outcome should default to TestOutcome.NotExecuted
Assert.AreEqual(TestOutcome.NotExecuted, result.Outcome);
}

/// <summary>
/// Tests that <see cref="TestResult.ErrorMessage" /> defaults to an empty string
/// </summary>
[TestMethod]
public void TestResult_ErrorMessage_Default_IsEmpty()
{
// Arrange - create a new TestResult with default property values

// Act
var result = new TestResult();

// Assert - ErrorMessage should default to string.Empty
Assert.AreEqual(string.Empty, result.ErrorMessage);
}

/// <summary>
/// Tests that <see cref="TestResult.ErrorStackTrace" /> defaults to an empty string
/// </summary>
[TestMethod]
public void TestResult_ErrorStackTrace_Default_IsEmpty()
{
// Arrange - create a new TestResult with default property values

// Act
var result = new TestResult();

// Assert - ErrorStackTrace should default to string.Empty
Assert.AreEqual(string.Empty, result.ErrorStackTrace);
}
}
Loading
Loading