Probability.IsTrue Method

Performs a weighted selection between true and false.

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

Usage

'Usage

Syntax

'Declaration
public static bool IsTrue (
    double probabilityForTrue
)

Parameters

  • probabilityForTrue
    The probability with which this method should return true.

Return Value

The selected Boolean value.

Example

The following example shows a Cord action declaration with embedded code. Each time this action occurs in a behavior, Spec Explorer selects with 50-percent probability between two alternative parameter domains.

action abstract static void SUT.CreateFile(string name, bool errorIfExists, bool appendAtEnd)
    where {.
        if (Probability.IsTrue(0.5))
        {
            Condition.In(name, "SecondParameter", "ThirdParameter");
        }
        else
        {
            Condition.In(name, "@^@\\");
        }
        Combination.Pairwise(name, errorIfExists, appendAtEnd);
        Combination.Expand(name, errorIfExists, appendAtEnd);
    .};

Exceptions

Exception type Condition
ArgumentException

probabilityForTrue is less than zero or greater than one.

Remarks

The chance that this method returns true is equal to probabilityForTrue.

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

Probability Class
Probability Members
Microsoft.Modeling Namespace