Class Matcher
Represents a matcher that can perform special data matching capabilities between a given pattern and a target.
Namespace: Amazon.CDK.Assertions
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public abstract class Matcher : DeputyBase
Syntax (vb)
Public MustInherit Class Matcher Inherits DeputyBase
Remarks
ExampleMetadata: infused
Examples
// Given a template -
// {
// "Resources": {
// "MyBar": {
// "Type": "Foo::Bar",
// "Properties": {
// "Fred": {
// "Wobble": ["Flob", "Flib"],
// }
// }
// }
// }
// }
// The following will NOT throw an assertion error
template.HasResourceProperties("Foo::Bar", new Dictionary<string, IDictionary<string, Matcher[]>> {
{ "Fred", new Struct {
Wobble = new [] { Match.AnyValue(), Match.AnyValue() }
} }
});
// The following will throw an assertion error
template.HasResourceProperties("Foo::Bar", new Dictionary<string, IDictionary<string, Matcher>> {
{ "Fred", new Struct {
Wimble = Match.AnyValue()
} }
});
Synopsis
Constructors
| Matcher() | Represents a matcher that can perform special data matching capabilities between a given pattern and a target. |
Properties
| Name | A name for the matcher. |
Methods
| IsMatcher(object) | Check whether the provided object is a subtype of the |
| Test(object) | Test whether a target matches the provided pattern. |
Constructors
Matcher()
Represents a matcher that can perform special data matching capabilities between a given pattern and a target.
protected Matcher()
Remarks
ExampleMetadata: infused
Examples
// Given a template -
// {
// "Resources": {
// "MyBar": {
// "Type": "Foo::Bar",
// "Properties": {
// "Fred": {
// "Wobble": ["Flob", "Flib"],
// }
// }
// }
// }
// }
// The following will NOT throw an assertion error
template.HasResourceProperties("Foo::Bar", new Dictionary<string, IDictionary<string, Matcher[]>> {
{ "Fred", new Struct {
Wobble = new [] { Match.AnyValue(), Match.AnyValue() }
} }
});
// The following will throw an assertion error
template.HasResourceProperties("Foo::Bar", new Dictionary<string, IDictionary<string, Matcher>> {
{ "Fred", new Struct {
Wimble = Match.AnyValue()
} }
});
Properties
Name
A name for the matcher.
public abstract string Name { get; }
Property Value
Remarks
This is collected as part of the result and may be presented to the user.
Methods
IsMatcher(object)
Check whether the provided object is a subtype of the IMatcher.
public static bool IsMatcher(object x)
Parameters
- x object
Returns
Remarks
ExampleMetadata: infused
Test(object)
Test whether a target matches the provided pattern.
public abstract MatchResult Test(object actual)
Parameters
- actual object
the target to match.
Returns
the list of match failures. An empty array denotes a successful match.
Remarks
Every Matcher must implement this method. This method will be invoked by the assertions framework. Do not call this method directly.