ErrorModeAttribute Class
Namespace: Microsoft.Modeling
Assembly: Microsoft.Xrt.Runtime (in Microsoft.Xrt.Runtime.dll)
The following example shows a model program that makes use of various mode attributes to describe parts of the model behavior.
using Microsoft.Modeling; namespace Modes { [InitialMode("Unstarted")] [AcceptingMode("Finished")] [AcceptingMode("Unstarted")] [ErrorMode("StartError")] static class ModesModelProgram { static int jobCount = 0; [Probe] public static string CountProbe { get { return string.Format("Jobs: {0}", jobCount); } } [AcceptingStateCondition] static bool IsAccepting { get { return jobCount == 0; } } [Rule(Action = "Start(initialCount)", ModeTransition = "Unstarted->Running")] static void Start(int initialCount) { Condition.IsTrue(initialCount > 0); jobCount = initialCount; } [Rule(Action = "Start(initialCount)", ModeTransition = "Unstarted->StartError")] static void StartError(int initialCount) { Condition.IsFalse(initialCount > 0); } [Rule(Action = "DoNext", ModeTransition = "Running->Running")] static void DoNext() { Condition.IsTrue(jobCount > 0); jobCount--; } [Rule(Action = "Stop/result", ModeTransition = "Running->Finished")] static int Stop() { Condition.IsTrue(jobCount == 0); return jobCount; } [Rule(Action = "Stop/result", ModeTransition = "Running->JobError")] static int StopError() { Condition.IsFalse(jobCount == 0); return jobCount; } [Rule(ModeTransition = "Finished->Unstarted")] static void Reset() { jobCount = 0; } } }
When one or more error mode sets are defined, Spec Explorer will mark a state as an error state during exploration if any of the error mode sets is a subset of the mode set for the state. Spec Explorer does not examine any outgoing transitions from such an error state. For more information about using mode transitions, see Mode Sets.
Note: |
|---|
| Spec Explorer cannot construct test cases from a behavior that contains error states. |
Spec Explorer's validation process checks the value of the Mode property and generates a validation error if the value of the property is invalid. The compiler does not identify such errors.
For more information about using attributes, see Extending Metadata Using Attributes.
Development Platforms
Microsoft Windows 7, Microsoft Windows Vista, Microsoft Windows XP SP2 or later, Microsoft Windows Server 2008, Microsoft Windows Server 2003
Note: