Class UnitTest
A unit test.
[DataContract(IsReference = true)]
[KnownType(typeof(TestType))]
[KnownType(typeof(UnitStation))]
[KnownType(typeof(Override))]
public class UnitTest
- Inheritance
-
UnitTest
- Inherited Members
Constructors
UnitTest(int, DateTime, TestType, UnitStation)
Initializes a new instance of the UnitTest class.
public UnitTest(int unitTestId, DateTime testDateTime, TestType testType, UnitStation unitStation)
Parameters
unitTestIdintThe unique identifier for this unit test.
testDateTimeDateTimeThe date/time when this test was performed, in UTC.
testTypeTestTypeThe test type.
unitStationUnitStationThe unit station at which this occurred.
Exceptions
- ArgumentNullException
testTypeis null.- ArgumentNullException
unitStationis null.
Properties
CustomTestData
Gets or sets the list of custom test data items. This can be null.
public IList<CustomTestDataItem>? CustomTestData { get; set; }
Property Value
Data
Gets optional custom data for this test, as XML.
[DataMember(Order = 2)]
public string? Data { get; set; }
Property Value
Notes
Gets or sets optional notes about this test.
[DataMember]
public string? Notes { get; set; }
Property Value
Override
Gets or sets the override for this test, if one exists.
[DataMember]
public Override? Override { get; set; }
Property Value
Passed
Gets or sets whether this test passed.
[DataMember]
public bool Passed { get; set; }
Property Value
Reason
Gets or sets the optional reason for a test not passing.
[DataMember]
public string? Reason { get; set; }
Property Value
TestDateTime
Gets the date/time when this test was performed, in UTC.
[DataMember]
public DateTime TestDateTime { get; }
Property Value
TestType
Gets the test type.
[DataMember]
public TestType TestType { get; }
Property Value
UnitStation
Gets the unit station at which this occurred.
[DataMember]
public UnitStation UnitStation { get; }
Property Value
UnitTestId
Gets the unique identifier for this unit test.
[DataMember]
public int UnitTestId { get; }
Property Value
Methods
EncodeTestDataAsXml(IEnumerable<CustomTestDataItem>?)
Encodes test data as XML.
public static string? EncodeTestDataAsXml(IEnumerable<CustomTestDataItem>? testDataItems)
Parameters
testDataItemsIEnumerable<CustomTestDataItem>The test data items. This can be null.
Returns
Remarks
See the remarks for ParseXmlTestData(string?) for details about the XML format.
MigrateXmlDataToCustomTestData()
Migrate the XML test data in the Data property to CustomTestData.
public void MigrateXmlDataToCustomTestData()
Remarks
If there is no XML test data (i.e., Data is null or the XML contains no child elements), then CustomTestData will not be changed. If there is any XML test data, then CustomTestData will be created if it was previously null, and then the test data will be added to the list. If this method is called multiple times, the test data will be copied multiple times.
See ParseXmlTestData(string?) for details about how the XML test data is parsed.
ParseXmlTestData(string?)
Parse XML test data.
public static IReadOnlyList<CustomTestDataItem> ParseXmlTestData(string? xmlTestData)
Parameters
Returns
- IReadOnlyList<CustomTestDataItem>
A list of CustomTestDataItem objects representing the parsed test data. This will be an empty list if
xmlTestDatais null or empty.
Remarks
Each child element of the root XML element will become an item in the sequence. For each item, the element name will be used for Name (unless the "name" attribute is specified, as described below), the element's concatenated text content will be used for Value, and the following optional attributes of the element will be used as described below:
| Attribute | Description |
|---|---|
| name | The name to use for Name. If specified, this will be used instead of the element name, which allows test data items to be given names that don't have to be valid XML element names. |
| status | A status indication value to use for Status, which can be: None, Good, or Bad. |
| details | Additional details to use for AdditionalDetails. |