Class ExpectedResult
(experimental) Represents the "expected" results to compare.
Inheritance
Namespace: Amazon.CDK.IntegTests.Alpha
Assembly: Amazon.CDK.IntegTests.Alpha.dll
Syntax (csharp)
public abstract class ExpectedResult : DeputyBase
Syntax (vb)
Public MustInherit Class ExpectedResult
Inherits DeputyBase
Remarks
Stability: Experimental
ExampleMetadata: infused
Examples
App app;
IntegTest integ;
integ.Assertions.AwsApiCall("SQS", "sendMessage", new Dictionary<string, string> {
{ "QueueUrl", "url" },
{ "MessageBody", "hello" }
});
var message = integ.Assertions.AwsApiCall("SQS", "receiveMessage", new Dictionary<string, string> {
{ "QueueUrl", "url" }
});
message.Expect(ExpectedResult.ObjectLike(new Dictionary<string, object> {
{ "Messages", new [] { new Dictionary<string, string> { { "Body", "hello" } } } }
}));
Synopsis
Constructors
ExpectedResult() | |
ExpectedResult(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
ExpectedResult(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Properties
Result | (experimental) The expected results encoded as a string. |
Methods
ArrayWith(Object[]) | (experimental) The actual results must be a list and must contain an item with the expected results. |
Exact(Object) | (experimental) The actual results must match exactly. |
ObjectLike(IDictionary<String, Object>) | (experimental) The expected results must be a subset of the actual results. |
StringLikeRegexp(String) | (experimental) Actual results is a string that matches the Expected result regex. |
Constructors
ExpectedResult()
protected ExpectedResult()
Remarks
Stability: Experimental
ExpectedResult(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected ExpectedResult(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
ExpectedResult(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected ExpectedResult(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Properties
Result
(experimental) The expected results encoded as a string.
public abstract string Result { get; set; }
Property Value
System.String
Remarks
Stability: Experimental
Methods
ArrayWith(Object[])
(experimental) The actual results must be a list and must contain an item with the expected results.
public static ExpectedResult ArrayWith(object[] expected)
Parameters
- expected System.Object[]
Returns
Remarks
Stability: Experimental
Examples
// actual results
IDictionary<string, string>[] actual = new [] { new Dictionary<string, string> {
{ "stringParam", "hello" }
}, new Dictionary<string, string> {
{ "stringParam", "world" }
} };
// pass
ExpectedResult.ArrayWith(new [] { new Dictionary<string, string> {
{ "stringParam", "hello" }
} });
Exact(Object)
(experimental) The actual results must match exactly.
public static ExpectedResult Exact(object expected)
Parameters
- expected System.Object
Returns
Remarks
Missing data will result in a failure
Stability: Experimental
See: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.assertions.Match.html#static-exactpattern
Examples
// actual results
IDictionary<string, object> actual = new Dictionary<string, object> {
{ "stringParam", "hello" },
{ "numberParam", 3 },
{ "booleanParam", true }
};
// pass
ExpectedResult.Exact(new Dictionary<string, object> {
{ "stringParam", "hello" },
{ "numberParam", 3 },
{ "booleanParam", true }
});
// fail
ExpectedResult.Exact(new Dictionary<string, string> {
{ "stringParam", "hello" }
});
ObjectLike(IDictionary<String, Object>)
(experimental) The expected results must be a subset of the actual results.
public static ExpectedResult ObjectLike(IDictionary<string, object> expected)
Parameters
- expected System.Collections.Generic.IDictionary<System.String, System.Object>
Returns
Remarks
Stability: Experimental
Examples
// actual results
IDictionary<string, object> actual = new Dictionary<string, object> {
{ "stringParam", "hello" },
{ "numberParam", 3 },
{ "booleanParam", true },
{ "objectParam", new Dictionary<string, string> { { "prop1", "value" }, { "prop2", "value" } } }
};
// pass
ExpectedResult.ObjectLike(new Dictionary<string, object> {
{ "stringParam", "hello" },
{ "objectParam", new Dictionary<string, string> { { "prop1", "value" } } }
});
StringLikeRegexp(String)
(experimental) Actual results is a string that matches the Expected result regex.
public static ExpectedResult StringLikeRegexp(string expected)
Parameters
- expected System.String
Returns
Remarks
Stability: Experimental
Examples
// actual results
var actual = "some string value";
// pass
ExpectedResult.StringLikeRegexp("value");