Class BaseContentValidator
- Namespace
- Xping.Sdk.Validations.Content
- Assembly
- Xping.Sdk.dll
Represents an abstract base class for validating HTTP content.
public abstract class BaseContentValidator : TestComponent, ITestComponent
- Inheritance
-
BaseContentValidator
- Implements
- Derived
- Inherited Members
Remarks
The BaseContentValidator class inherits from the TestComponent class and provides a common method for decoding HTTP content.
Constructors
BaseContentValidator(string)
Represents an abstract base class for validating HTTP content.
protected BaseContentValidator(string name)
Parameters
name
string
Remarks
The BaseContentValidator class inherits from the TestComponent class and provides a common method for decoding HTTP content.
Methods
GetBrowserResponseMessage(TestContext)
Retrieves the BrowserResponseMessage from the TestContext.
protected virtual BrowserResponseMessage? GetBrowserResponseMessage(TestContext context)
Parameters
context
TestContextThe TestContext instance containing the property bag values.
Returns
- BrowserResponseMessage
The BrowserResponseMessage if it exists in the property bag; otherwise, null.
Remarks
This method attempts to retrieve the BrowserResponseMessage from the TestContext's non-serializable property bag. If it is not found, the method returns null.
GetContent(byte[], HttpContentHeaders)
Decodes the HTTP content from a byte array and content headers.
protected virtual string GetContent(byte[] data, HttpContentHeaders contentHeaders)
Parameters
data
byte[]The byte array that contains the HTTP content.
contentHeaders
HttpContentHeadersThe content headers that specify the encoding and media type of the content.
Returns
- string
A string representation of the HTTP content.
Exceptions
- ArgumentNullException
Thrown when the data or contentHeaders parameter is null.
- DecoderFallbackException
Thrown when a decoder fallback operation fails.
GetData(TestContext)
Retrieves the data (as a byte array) from the TestContext.
protected virtual byte[] GetData(TestContext context)
Parameters
context
TestContextThe TestContext instance containing the property bag values.
Returns
- byte[]
The data as a byte array if it exists in the property bag; otherwise, an empty byte array.
Remarks
This method attempts to retrieve the data from the TestContext's property bag. If the data is not found, it returns an empty byte array.
GetHttpResponseMessage(TestContext)
Retrieves the HttpResponseMessage from the TestContext.
protected virtual HttpResponseMessage? GetHttpResponseMessage(TestContext context)
Parameters
context
TestContextThe TestContext instance containing the property bag values.
Returns
- HttpResponseMessage
The HttpResponseMessage if it exists in the property bag; otherwise, the HttpResponseMessage contained within the BrowserResponseMessage, or null if neither are found.
Remarks
This method first attempts to retrieve the HttpResponseMessage directly from the TestContext's non-serializable property bag. If it is not found, it then attempts to retrieve the BrowserResponseMessage from the property bag and return its associated HttpResponseMessage.