Writing Specifications

Specifications are used to retrieve information. You write them using LINQ. Given a starting point, the specification finds all facts that match a set of conditions.

var postsInSite = Given<Site>.Match((site, facts) =>
  from post in facts.OfType<Post>()
  where post.site == site
  select post
);

Call the jinagaClient.Query method to retrieve the facts.

var posts = await jinagaClient.Query(postsInSite, site);

If you prefer LINQ method syntax, you can write the specification like this.

var postsInSite = Given<Site>.Match((site, facts) =>
  facts.OfType<Post>()
    .Where(post => post.site == site)
);

You can even pass the condition lambda into the OfType method.

var postsInSite = Given<Site>.Match((site, facts) =>
  facts.OfType<Post>(post => post.site == site)
);

Continue With

Projecting Results

Jinaga is a product of Jinaga LLC.

Michael L Perry, President