Helper classes for using Siren Hypermedia in .NET.
D2L.Hypermedia.Siren
fully supports Siren Hypermedia. For more information, see the link above.
ISirenEntity entity = new SirenEntity(
links: new [] {
new SirenLink( rel: "self", href: new Uri( "http://example.com" )
},
actions: new [] {
new SirenAction(
name: "my-action",
method: "GET",
href: new Uri( "http://example.com/action" ),
fields: new [] {
new SirenField( name: "my-field", type: "number", value: 1 )
}
)
},
title: "Entity title",
...
);
There are numerous extension methods which allow you to extract a Siren representation from its parent, e.g.
ISirenAction action;
sirenEntity.TryGetActionByName( "my-action", out action );
In addition to these, SirenMatchers
is a static class which contains a set of Matches()
functions. These are mostly intended to be used in testing, and they will return true if the expected
Siren representation is contained within/matches the actual
Siren representation, e.g.
ISirenEntity expectedEntity = new SirenEntity(
title: "Entity title",
actions: new [] {
new SirenAction( name: "my-action" )
}
);
string message;
Assert.IsTrue( SirenMatchers.Matches( expectedEntity, actualEntity, out message ), message );
This will verify that actualEntity
at least contains what was specified in expectedEntity
. If a match is not found, message
will identify where it differs.
Note: Currently,
SirenMatchers
will not properly check Siren Properties. This is becauseISirenEntity.Properties
isdynamic
, which is difficult to test equality on in a reliable way. A future version may change this, but until then, properties must be manually checked for equality.
-
Fork the repository. Committing directly against this repository is highly discouraged.
-
Make your modifications in a branch, updating and writing new tests.
-
Ensure that all tests pass.
-
rebase
your changes against master. Do not merge. -
Submit a pull request to this repository. Wait for tests to run and someone to chime in.
-
Merge pull request to master
-
Create release in GitHub, with a semver name of the format "v1.2.3"
-
Appveyor will run on the new tag, and upload the new version to NuGet automatically