ARCExpect API design
The main goal of ARCExpect is providing an API surface that creates the common validatiopn cases without the need for much custom input. The following principles guide the design of the API:
- Semantic: Creating a validation case should be as easy as expressing it in words. Therefore, the API should be as close as possible to the natural language.
- Simple: The API should be simple to use and understand. It should not require a lot of boilerplate code to create a validation case.
- Customizable: As is always the case, there are exceptions to the rule where the API should be flexible enough to allow for custom validation cases.
API Design
Semantic Methods for validation case creation in the Validate
namespace
Methods in the Validate
(sub)namespace(s) should mirror an english sentence in the imperative mood of the following form, where words in brackets ()
are left out for brevity and/or are optional, and words in angle brackets <>
are placeholders for the actual values:
Validate.
(for <article>
)<object>
(that)<predicate>
(is true)
examples:
-
Validate.Param.ValueIsEqualTo(expectedValue)
method represents:Validate
(for a)param
(eter that it's)value is equal to
(the)value <expected value>
-
Validate.ParamCollection.ContainsParamWithTerm(expectedTerm)
method represents:Validate
(for a)param
(eter)collection
(that it)contains
(a)parameter with
(the)term <expected term>
Objects
As validation cases are fundamentally built for validating ControlledVocabulary Tokens (CvParam
s / IParam
s), this reflected in the objects of the 'sentences' provided as methods of the API.
The following objects should be supported:
Param
represents a single object implementing theIParam
interface.ParamCollection
represents a collection ofIParam
s.
Predicates
Predicates are the conditions that the object(s) should satisfy. Generic methods should be provided to cover predicates that are not directly provided by the API to satisfy the Customizable principle. The following predicates should be supported out of the box:
Object |
Predicate |
Signature |
Description |
---|---|---|---|
|
|
|
generic method to validate wether a single |
|
|
|
validates wether the given param is exactly equal (structural equality regarding all object fields) to the expected param |
|
|
|
validates wether the given param's value is equal to the expected |
|
|
|
validates wether the given param's term is equal to the expected |
|
|
|
generic method to validate wether a collection of |
|
|
|
validates that the given collection of |
|
|
|
validates wether the given collection of |
|
|
|
generic method to validate wether all items in a collection of |
|
|
|
generic method to validate wether at least one item in a collection of |
|
|
|
validates wether the given collection of |
|
|
|
validates wether the given collection of |
|
|
|
validates wether the given collection of |