Interface IDeployAssert
(experimental) Interface that allows for registering a list of assertions that should be performed on a construct.
Namespace: Amazon.CDK.IntegTests.Alpha
Assembly: Amazon.CDK.IntegTests.Alpha.dll
Syntax (csharp)
public interface IDeployAssert
Syntax (vb)
Public Interface IDeployAssert
Remarks
This is only necessary when writing integration tests.
Stability: Experimental
Synopsis
Methods
AwsApiCall(String, String, Object, String[]) | (experimental) Query AWS using JavaScript SDK API calls. |
Expect(String, ExpectedResult, ActualResult) | (experimental) Assert that the ExpectedResult is equal to the ActualResult. |
HttpApiCall(String, IFetchOptions) | (experimental) Make an HTTP call to the provided endpoint. |
InvokeFunction(ILambdaInvokeFunctionProps) | (experimental) Invoke a lambda function and return the response which can be asserted. |
Methods
AwsApiCall(String, String, Object, String[])
(experimental) Query AWS using JavaScript SDK API calls.
IApiCall AwsApiCall(string service, string api, object parameters = null, string[] outputPaths = null)
Parameters
- service System.String
- api System.String
- parameters System.Object
- outputPaths System.String[]
Returns
Remarks
This can be used to either trigger an action or to return a result that can then be asserted against an expected value
The service
is the name of an AWS service, in one of the following forms:
The api
is the name of an AWS API call, in one of the following forms:
Stability: Experimental
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" } } } }
}));
Expect(String, ExpectedResult, ActualResult)
(experimental) Assert that the ExpectedResult is equal to the ActualResult.
void Expect(string id, ExpectedResult expected, ActualResult actual)
Parameters
- id System.String
- expected ExpectedResult
- actual ActualResult
Remarks
Stability: Experimental
Examples
IntegTest integ;
AwsApiCall apiCall;
integ.Assertions.Expect("invoke", ExpectedResult.ObjectLike(new Dictionary<string, object> { { "Payload", "OK" } }), ActualResult.FromAwsApiCall(apiCall, "Body"));
HttpApiCall(String, IFetchOptions)
(experimental) Make an HTTP call to the provided endpoint.
IApiCall HttpApiCall(string url, IFetchOptions options = null)
Parameters
- url System.String
- options IFetchOptions
Returns
Remarks
Stability: Experimental
Examples
App app;
IntegTest integ;
var call = integ.Assertions.HttpApiCall("https://example.com/test");
call.Expect(ExpectedResult.ObjectLike(new Dictionary<string, object> {
{ "Message", "Hello World!" }
}));
InvokeFunction(ILambdaInvokeFunctionProps)
(experimental) Invoke a lambda function and return the response which can be asserted.
IApiCall InvokeFunction(ILambdaInvokeFunctionProps props)
Parameters
Returns
Remarks
Stability: Experimental
Examples
App app;
IntegTest integ;
var invoke = integ.Assertions.InvokeFunction(new LambdaInvokeFunctionProps {
FunctionName = "my-function"
});
invoke.Expect(ExpectedResult.ObjectLike(new Dictionary<string, object> {
{ "Payload", "200" }
}));