Compartir a través de


Requirement Class

Allows a requirement to be marked as captured at a point in a model program.

Namespace: Microsoft.Modeling
Assembly: Microsoft.Xrt.Runtime (in Microsoft.Xrt.Runtime.dll)

Usage

'Usage

Syntax

'Declaration
public static class Requirement

Example

The following example uses the Capture, AssumeCaptured, and IsTrue methods to indicate when a specific requirement is captured by the AddJob action.

static SetContainer<int> activeJobIds = new SetContainer<int>();

/// <summary>Models a request to add a job to the queue.</summary>
/// <param name="jobId">The job identifier.</param>
/// <param name="jobName">The job name.</param>
/// <returns>true if the job was successfully added; otherwise, false.
/// </returns>
[Rule]
static bool AddJob(int jobId, string jobName)
{
    // Requirement 1: Job identifiers MUST be greater than zero.
    // Requirement 2: Active jobs MUST have a unique identifier.
    // Requirement 3: Job identifier MUST be encrypted with SHA-01.

    Condition.IsTrue(jobId > 0, "req-01");

    bool success = !activeJobIds.Contains(jobId);
    if (success)
    {
        activeJobIds.Add(jobId);
        Requirement.Capture("req-02");
    }

    // This requirement can be only validated by the adapter.
    Requirement.AssumeCaptured("req-03");

    return success;
}

Remarks

To indicate that a model captures a requirement, insert a call to the Capture or AssumeCaptured method at a point in the model program where the model has validated the requirement. When Spec Explorer encounters a capture method during exploration, it adds the requirement to the set of captured requirements for the step that is being explored.

We recommend that you use a requirement identifier in the requirement parameter in calls to the Capture or AssumeCaptured method, instead of a requirement description. The Condition.IsTrue(Boolean,String) method is equivalent to the combination of the Condition.IsTrue(Boolean) and Capture methods

The set of requirements captured by a step is the set of unique requirements captured in the transition that are not already captured in the transition's source state. In Exploration Graph Viewer, the step browser displays the requirements captured by a step. To have Exploration Graph Viewer include captured requirements as part of step labels, create a view definition for which DisplayRequirements is set to true.

Spec Explorer makes requirement capture available at test time. If a step captures a set of requirements, when a test validates the step on or against the system under test, the test logs the captured requirements.

To define a behavior in Cord script based on capturing requirements, use the requirement coverage construct, RequirementCoverageConstruct.

Inheritance Hierarchy

System.Object
  Microsoft.Modeling.Requirement

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

Microsoft Windows 7, Microsoft Windows Vista, Microsoft Windows XP SP2 or later, Microsoft Windows Server 2008, Microsoft Windows Server 2003

Change History

See Also

Reference

Requirement Members
Microsoft.Modeling Namespace
Condition.IsTrue Method (Boolean, String)

Other Resources

RequirementCoverageConstruct