### Run ImageGalleryService Source: https://github.com/microsoft/coyote/blob/main/Samples/WebApps/ImageGalleryAspNet/ImageGallery/readme.md Commands to navigate to the service directory and start the application. ```shell cd ..\ImageGalleryService dotnet run ``` -------------------------------- ### Run ImageGallery Client Source: https://github.com/microsoft/coyote/blob/main/Samples/WebApps/ImageGalleryAspNet/ImageGallery/readme.md Commands to navigate to the client directory and start the application. ```shell cd ..\ImageGallery dotnet run ``` -------------------------------- ### Install Coyote NuGet Packages and CLI Source: https://context7.com/microsoft/coyote/llms.txt Install the Coyote meta-package or individual packages for your project. The Coyote CLI tool can be installed globally or locally for a specific repository. ```bash dotnet add .csproj package Microsoft.Coyote dotnet add .csproj package Microsoft.Coyote.Core dotnet add .csproj package Microsoft.Coyote.Test dotnet tool install --global Microsoft.Coyote.CLI dotnet tool update --global Microsoft.Coyote.CLI dotnet new tool-manifest dotnet tool install --local Microsoft.Coyote.CLI dotnet tool restore ``` -------------------------------- ### Setup Python Environment with Conda Source: https://github.com/microsoft/coyote/blob/main/Scripts/Notebooks/AzurePerformanceGraphs.ipynb Use this command to create and activate a new conda environment for the Coyote project, install dependencies, and open the project in VS Code. ```bash conda create -n coyote python=3.9 conda activate coyote pip install -r requirements.txt pip install -U ipykernel code . ``` -------------------------------- ### Get Testing Report Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.SystematicTesting/TestingEngine/GetReport.md Call this method to obtain a report of the testing results. No setup or imports are required beyond having an instance of the TestingEngine. ```csharp public string GetReport() ``` -------------------------------- ### Install Coyote CLI Tool Locally Source: https://github.com/microsoft/coyote/blob/main/docs/get-started/install.md Install the 'coyote' command-line tool locally within a specific repository. This requires creating a tool manifest first. ```bash dotnet new tool-manifest ``` ```bash dotnet tool install --local Microsoft.Coyote.CLI ``` -------------------------------- ### Example Program Output Source: https://github.com/microsoft/coyote/blob/main/docs/concepts/actors/overview.md Sample log output demonstrating interleaved actor operations. ```plain Client(3) initializing Client(3) sending ping event to server Client(1) initializing Client(2) initializing Client(2) sending ping event to server Client(1) sending ping event to server Server handling ping from Client(1) Server sending pong back to caller Client(1) received pong event Server handling ping from Client(3) Server sending pong back to caller Server handling ping from Client(2) Server sending pong back to caller Client(2) received pong event Client(3) received pong event ``` -------------------------------- ### Access the Current ICoyoteRuntime Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Runtime/RuntimeProvider/Current.md Use the static Current property to get the runtime installed in the current execution context. No setup is required. ```csharp public static ICoyoteRuntime Current { get; } ``` -------------------------------- ### Operation.Start Method Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Runtime/Operation/Start.md Starts executing the operation with the specified id. ```APIDOC ## Operation.Start ### Description Starts executing the operation with the specified id. ### Method static void ### Parameters #### Path Parameters - **operationId** (ulong) - Required - The unique identifier of the operation to start. ``` -------------------------------- ### Install and update the Coyote CLI tool Source: https://github.com/microsoft/coyote/blob/main/docs/get-started/build-source.md Commands for installing the locally built CLI tool or uninstalling an existing version. ```bash dotnet tool install --global --add-source ./bin/nuget Microsoft.Coyote.CLI ``` ```bash dotnet tool uninstall --global Microsoft.Coyote.CLI ``` -------------------------------- ### Example Trace Logs Source: https://github.com/microsoft/coyote/blob/main/docs/tutorials/testing-aspnet-service.md These are example logs from a Coyote trace, showing unique HTTP context trace identifiers that help visualize concurrent task interleaving during testing. ```text [0HM34OD7O65E5] Creating account with id '0' (name: 'alice', email: 'alice@coyote.com'). [0HM34OD7O65E5] Creating container 'Accounts' in database 'ImageGalleryDB' if it does not exist. [0HM34OD7O65E5] Checking if item with partition key '0' and id '0' exists in container 'Accounts'. [0HM34OD7O65E5] Creating new item with partition key '0' and id '0' in container 'Accounts'. [0HM34OD7O65E7] Storing image with name 'beach' and account id '0'. [0HM34OD7O65E6] Deleting account with id '0'. [0HM34OD7O65E6] Creating container 'Accounts' in database 'ImageGalleryDB' if it does not exist. [0HM34OD7O65E7] Creating container 'Accounts' in database 'ImageGalleryDB' if it does not exist. [0HM34OD7O65E7] Checking if item with partition key '0' and id '0' exists in container 'Accounts'. [0HM34OD7O65E6] Checking if item with partition key '0' and id '0' exists in container 'Accounts'. [0HM34OD7O65E6] Deleting item with partition key '0' and id '0' in container 'Accounts'. [0HM34OD7O65E7] Creating container 'gallery-0' if it does not exist. [0HM34OD7O65E6] Deleting container 'gallery-0' if it exists. [0HM34OD7O65E7] Creating blob 'beach' in container 'gallery-0'. ``` -------------------------------- ### Install Coyote CLI Tool Globally Source: https://github.com/microsoft/coyote/blob/main/docs/get-started/install.md Install the cross-platform 'coyote' command-line tool globally for the current user. This allows you to use 'coyote' commands from any directory. ```bash dotnet tool install --global Microsoft.Coyote.CLI ``` -------------------------------- ### Coyote Test Output Example Source: https://github.com/microsoft/coyote/blob/main/docs/tutorials/first-concurrency-unit-test.md Example output showing the results of a systematic test run that identified a bug. ```plain . Testing .\AccountManager.dll ... Method TestConcurrentAccountCreation ... Started the testing task scheduler (process:17368). ... Created '1' testing task (process:17368). ... Task 0 is using 'random' strategy (seed:1046544966). ..... Iteration #1 ..... Iteration #2 ..... Iteration #3 ..... Iteration #4 ..... Iteration #5 ..... Iteration #6 ..... Iteration #7 ..... Iteration #8 ..... Iteration #9 ..... Iteration #10 ..... Iteration #20 ... Task 0 found a bug. ... Emitting task 0 traces: ..... Writing AccountManager.dll\CoyoteOutput\AccountManager_0_0.txt ..... Writing AccountManager.dll\CoyoteOutput\AccountManager_0_0.trace ... Elapsed 0.0743756 sec. ... Testing statistics: ..... Found 1 bug. ... Exploration statistics: ..... Explored 26 schedules: 26 fair and 0 unfair. ..... Found 3.85% buggy schedules. ..... Number of scheduling decisions in fair terminating schedules: 17 (min), 23 (avg), 31 (max). ... Elapsed 0.1574494 sec. ``` -------------------------------- ### RaiseGotoStateEvent Shorthand Example Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Actors/StateMachine/RaiseGotoStateEvent.md Illustrates the equivalent behavior of the RaiseGotoStateEvent method using standard event raising syntax. ```csharp class Event E { } [OnEventGotoState(typeof(E), typeof(S))] this.RaiseEvent(new E()); ``` -------------------------------- ### Integrate Coyote rewriting into MSBuild Source: https://github.com/microsoft/coyote/blob/main/docs/concepts/binary-rewriting.md Example of a post-build task to automate binary rewriting. ```xml ``` -------------------------------- ### Example test execution output Source: https://github.com/microsoft/coyote/blob/main/docs/tutorials/testing-aspnet-service.md Typical output format when running the unit tests via the .NET CLI. ```text Total tests: 2 Passed: 2 Total time: 1.2053 Seconds ``` -------------------------------- ### InvokeStartIterationCallBacks Method Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.SystematicTesting/TestingEngine/InvokeStartIterationCallBacks.md Invokes any registered callbacks at the start of the specified iteration. ```APIDOC ## InvokeStartIterationCallBacks ### Description Invokes any registered callbacks at the start of the specified iteration. ### Parameters #### Parameters - **iteration** (uint) - Required - The iteration number for which to invoke callbacks. ### Method Signature `public void InvokeStartIterationCallBacks(uint iteration)` ``` -------------------------------- ### Locate Coyote Output Files Source: https://github.com/microsoft/coyote/blob/main/docs/tutorials/actors/test-failover.md Path examples for the generated test output log and DGML diagram files. ```plain .\Samples\bin\net8.0\Output\CoffeeMachineActors.exe\CoyoteOutput\CoffeeMachine_0_0.txt .\Samples\bin\net8.0\Output\CoffeeMachineActors.exe\CoyoteOutput\CoffeeMachine_0_0.dgml ``` -------------------------------- ### Build the ASP.NET sample Source: https://github.com/microsoft/coyote/blob/main/docs/tutorials/testing-aspnet-service.md Build the Image Gallery ASP.NET sample project. Ensure you have cloned the Coyote git repository and navigated to the correct directory. ```bash cd Samples/WebApps/ImageGalleryAspNet/ dotnet build ``` -------------------------------- ### Create a new configuration Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote/Configuration/Create.md Initializes a configuration instance with default settings. ```csharp public static Configuration Create() ``` -------------------------------- ### Write unit test for AccountManager Source: https://github.com/microsoft/coyote/blob/main/docs/tutorials/first-concurrency-unit-test.md A basic unit test setup using the InMemoryDbCollection mock. ```csharp [Test] public static async Task TestAccountCreation() { // Initialize the mock in-memory DB and account manager. var dbCollection = new InMemoryDbCollection(); var accountManager = new AccountManager(dbCollection); // Create some dummy data. ``` -------------------------------- ### Get SharedCounter Value Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Actors.SharedObjects/SharedCounter/GetValue.md Use this method to retrieve the current integer value of a shared counter. No specific setup or imports are required beyond having an instance of SharedCounter. ```csharp public virtual int GetValue() ``` -------------------------------- ### Define Setup Event for Client Initialization Source: https://context7.com/microsoft/coyote/llms.txt Define a 'SetupEvent' to pass necessary information, such as the server's ActorId, during the client state machine's initialization. ```csharp public class SetupEvent : Event { public ActorId ServerId { get; } public SetupEvent(ActorId serverId) => ServerId = serverId; } ``` -------------------------------- ### Coyote Test Execution Output Source: https://github.com/microsoft/coyote/blob/main/docs/tutorials/test-concurrent-operations.md Example output from a successful Coyote test run, indicating that the testing task scheduler started, tasks were created, and iterations were completed without reporting bugs. ```plain . Testing .\AccountManager.dll ... Method TestConcurrentAccountCreationAndDeletion ... Started the testing task scheduler (process:25840). ... Created '1' testing task (process:25840). ... Task 0 is using 'random' strategy (seed:2968084874). ..... Iteration #1 ..... Iteration #2 ..... Iteration #3 ..... Iteration #4 ..... Iteration #5 ..... Iteration #6 ..... Iteration #7 ..... Iteration #8 ..... Iteration #9 ..... Iteration #10 ..... Iteration #20 ..... Iteration #30 ``` -------------------------------- ### View Production Output Log Source: https://github.com/microsoft/coyote/blob/main/docs/tutorials/test-failover.md Example of successful production output showing normal coffee level progression. ```xml Grinding beans... PortaFilter is 10 % full PortaFilter is 20 % full PortaFilter is 30 % full PortaFilter is 40 % full PortaFilter is 50 % full PortaFilter is 60 % full PortaFilter is 70 % full PortaFilter is 80 % full PortaFilter is 90 % full PortaFilter is full ``` -------------------------------- ### Define Operation.OnStarted method Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Runtime/Operation/OnStarted.md This method signature is used to register the start of an operation by its unique identifier. ```csharp public static void OnStarted(ulong operationId) ``` -------------------------------- ### Build Samples with Local Binaries Source: https://github.com/microsoft/coyote/blob/main/Samples/README.md Use this command to build the samples using locally built Coyote binaries. ```powershell ./Samples/Scripts/build.ps1 -local ``` -------------------------------- ### RuntimeProvider.Current Property Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Runtime/RuntimeProvider/Current.md The `Current` property returns the ICoyoteRuntime instance installed in the current execution context. ```APIDOC ## RuntimeProvider.Current Property ### Description The runtime installed in the current execution context. ### Method GET ### Endpoint N/A (Property Access) ### Parameters None ### Request Example None ### Response #### Success Response (200) - **ICoyoteRuntime** (interface) - The current ICoyoteRuntime instance. #### Response Example ```csharp ICoyoteRuntime runtime = RuntimeProvider.Current; ``` ### See Also * interface [ICoyoteRuntime](../ICoyoteRuntime.md) * class [RuntimeProvider](../RuntimeProvider.md) * namespace [Microsoft.Coyote.Runtime](../RuntimeProvider.md) * assembly [Microsoft.Coyote](../../Microsoft.Coyote.md) ``` -------------------------------- ### Implement a Client State Machine Source: https://context7.com/microsoft/coyote/llms.txt Develop a client state machine to interact with a server. This example shows how to send requests and handle responses, transitioning between states like 'Init' and 'Requesting'. ```csharp // Client state machine public class ClientStateMachine : StateMachine { private ActorId serverId; private int responsesReceived = 0; [Start] [OnEntry(nameof(OnInitEntry))] [OnEventGotoState(typeof(ReadyEvent), typeof(Requesting))] public class Init : State { } private void OnInitEntry(Event e) { var setup = (SetupEvent)e; this.serverId = setup.ServerId; this.RaiseEvent(new ReadyEvent()); } [OnEntry(nameof(SendRequest))] [OnEventDoAction(typeof(ResponseEvent), nameof(HandleResponse))] public class Requesting : State { } private void SendRequest() { this.SendEvent(this.serverId, new RequestEvent(this.Id)); } private void HandleResponse(Event e) { var response = (ResponseEvent)e; responsesReceived++; Console.WriteLine($"Client received: {response.Data}"); if (responsesReceived < 5) { // Send another request this.SendEvent(this.serverId, new RequestEvent(this.Id)); } } } ``` -------------------------------- ### Build PetImages ASP.NET Application Source: https://github.com/microsoft/coyote/blob/main/Samples/WebApps/PetImagesAspNet/README.md Build the sample application. This command also automatically rewrites the sample using Coyote via a post-build task. ```bash dotnet build ``` -------------------------------- ### Program Entry Point and Test Method Source: https://github.com/microsoft/coyote/blob/main/docs/samples/actors/failover-robot-navigator.md C# implementation showing the main entry point and the [Test] method used to register the LivenessMonitor and start the FailoverDriver. ```csharp public static class Program { private static bool RunForever = false; public static void Main() { ... RunForever = true; IActorRuntime runtime = RuntimeFactory.Create(conf); Execute(runtime); Console.ReadLine(); } [Microsoft.Coyote.SystematicTesting.Test] public static void Execute(IActorRuntime runtime) { runtime.RegisterMonitor(); ActorId driver = runtime.CreateActor(typeof(FailoverDriver), new FailoverDriver.ConfigEvent(RunForever)); } } ``` -------------------------------- ### Example Bug Error Output Source: https://github.com/microsoft/coyote/blob/main/docs/tutorials/testing-aspnet-service.md This is an example of a bug error message that Coyote might report, including the test name and instructions on how to replay the trace. ```text X TestConcurrentAccountRequests [10s 407ms] Error Message: Assert.Fail failed. Found bug: Found unexpected error code. Replay trace using Coyote by running: TraceReplayer.exe TestConcurrentAccountRequests TestConcurrentAccountRequests.trace ``` -------------------------------- ### Initialize RuntimeLogTextFormatter Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Runtime/RuntimeLogTextFormatter/RuntimeLogTextFormatter.md Use the default constructor to create a new instance of RuntimeLogTextFormatter. No specific setup is required. ```csharp public RuntimeLogTextFormatter() ``` -------------------------------- ### Build Coyote Samples Source: https://github.com/microsoft/coyote/blob/main/Samples/README.md Run this script from the repository root to compile the samples. ```powershell ./Samples/Scripts/build.ps1 ``` -------------------------------- ### Build Samples with Local NuGet Packages Source: https://github.com/microsoft/coyote/blob/main/Samples/README.md Use this command to build the samples using locally built Coyote NuGet packages. ```powershell ./Samples/Scripts/build.ps1 -local -nuget ``` -------------------------------- ### Monitor.State.StartAttribute Constructor Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Specifications/Monitor.State.StartAttribute/StartAttribute.md Documentation for the default constructor of the StartAttribute class. ```APIDOC ## Constructor: Monitor.State.StartAttribute() ### Description The default constructor for the StartAttribute class. ### Namespace Microsoft.Coyote.Specifications ### Assembly Microsoft.Coyote.dll ``` -------------------------------- ### InvokeStartIterationCallBacks Method Signature Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.SystematicTesting/TestingEngine/InvokeStartIterationCallBacks.md Defines the method signature for invoking iteration start callbacks in the TestingEngine class. ```csharp public void InvokeStartIterationCallBacks(uint iteration) ``` -------------------------------- ### Example Coyote Test Log Output Source: https://github.com/microsoft/coyote/blob/main/docs/how-to/unit-testing.md This is an example of the log file output generated by Coyote when a test fails due to an assertion. It includes the test log, error log, and stack trace. ```xml Running test. This test failed! at Microsoft.Coyote.SystematicTesting.OperationScheduler.NotifyAssertionFailure( String text, Boolean killTasks, Boolean cancelExecution) at Microsoft.Coyote.SystematicTesting.ControlledRuntime.Assert(Boolean predicate, String s) at ConsoleApp14.Test.CoyoteTestMethod() at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine]() at ConsoleApp14.Test.CoyoteTestMethod() at Microsoft.Coyote.SystematicTesting.ControlledRuntime.RunTestb__0d.MoveNext() at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine]() at Microsoft.Coyote.SystematicTesting.ControlledRuntime.RunTestb__0() at System.Threading.Tasks.Task.InnerInvoke() at System.Threading.Tasks.Task.c.cctorb__274_0(Object obj) at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop( Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task currentTaskSlot) at System.Threading.Tasks.Task.ExecuteEntryUnsafe(Thread threadPoolThread) ``` -------------------------------- ### Run unit tests for the ImageGallery service Source: https://github.com/microsoft/coyote/blob/main/docs/tutorials/testing-aspnet-service.md Commands to navigate to the project directory and execute the test suite using the .NET CLI. ```bash cd Samples/WebApps/ImageGalleryAspNet/ dotnet test bin/net8.0/ImageGalleryTests.dll ``` -------------------------------- ### Monitor.Logger Property Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Specifications/Monitor/Logger.md The logger installed to the runtime. ```APIDOC ## Monitor.Logger Property ### Description The logger installed to the runtime. ### Remarks See [Logging](/coyote/concepts/actors/logging) for more information. ### See Also * interface [ILogger](../../Microsoft.Coyote.Logging/ILogger.md) * class [Monitor](../Monitor.md) * namespace [Microsoft.Coyote.Specifications](../Monitor.md) * assembly [Microsoft.Coyote](../../Microsoft.Coyote.md) ``` -------------------------------- ### Implement a Server State Machine Source: https://context7.com/microsoft/coyote/llms.txt Create a server state machine with explicit states like 'Init', 'Active', and 'Error'. Use attributes like [Start], [OnEntry], and [OnEventGotoState] to define behavior and transitions. ```csharp // State machine with explicit states public class ServerStateMachine : StateMachine { private int requestCount = 0; // Initial state [Start] [OnEntry(nameof(OnInitEntry))] [OnEventGotoState(typeof(ReadyEvent), typeof(Active))] public class Init : State { } private void OnInitEntry() { Console.WriteLine("Server initializing..."); // Transition to Active state when ready this.RaiseEvent(new ReadyEvent()); } // Active state - handles requests [OnEntry(nameof(OnActiveEntry))] [OnEventDoAction(typeof(RequestEvent), nameof(HandleRequest))] [OnEventGotoState(typeof(ErrorEvent), typeof(Error))] public class Active : State { } private void OnActiveEntry() { Console.WriteLine("Server is now active"); } private void HandleRequest(Event e) { var request = (RequestEvent)e; requestCount++; Console.WriteLine($"Handling request #{requestCount}"); // Simulate potential error condition if (this.RandomInteger(10) == 0) { this.RaiseEvent(new ErrorEvent()); return; } // Send response this.SendEvent(request.Caller, new ResponseEvent($"Response #{requestCount}")); } // Error state [OnEntry(nameof(OnErrorEntry))] [OnEventGotoState(typeof(ReadyEvent), typeof(Active))] public class Error : State { } private void OnErrorEntry() { Console.WriteLine("Server encountered error, recovering..."); // Auto-recover after some time this.RaiseEvent(new ReadyEvent()); } } ``` -------------------------------- ### StateMachine.CurrentState Property Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Actors/StateMachine/CurrentState.md Gets the Type of the current state. ```APIDOC ## StateMachine.CurrentState Property ### Description Gets the Type of the current state. ### Method GET (Implicit - Property Access) ### Endpoint N/A (Property of a class) ### Parameters None ### Request Body None ### Request Example ```csharp Type currentState = myStateMachine.CurrentState; ``` ### Response #### Success Response (200) - **CurrentState** (Type) - The Type of the current state. ### Response Example ```json // Example of a Type returned (actual type depends on the state) "Microsoft.Coyote.Actors.States.MyState" ``` ``` -------------------------------- ### DefaultEvent.Instance Property Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Actors/DefaultEvent/Instance.md Gets a cached `DefaultEvent` instance. ```APIDOC ## DefaultEvent.Instance Property ### Description Gets a cached [`DefaultEvent`](../DefaultEvent.md) instance. ### Method GET ### Endpoint N/A (Property Access) ### Parameters N/A ### Request Example N/A ### Response #### Success Response (200) - **Instance** (DefaultEvent) - A cached `DefaultEvent` instance. #### Response Example ```csharp DefaultEvent cachedInstance = DefaultEvent.Instance; ``` ## See Also * class [DefaultEvent](../DefaultEvent.md) * namespace [Microsoft.Coyote.Actors](../DefaultEvent.md) * assembly [Microsoft.Coyote.Actors](../../Microsoft.Coyote.Actors.md) ``` -------------------------------- ### AwaitableEventGroup.GetAwaiter Method Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Actors/AwaitableEventGroup-1/GetAwaiter.md Gets an awaiter for this awaitable. ```APIDOC ## AwaitableEventGroup.GetAwaiter Method ### Description Gets an awaiter for this awaitable. ### Method public TaskAwaiter GetAwaiter() ### See Also * class [AwaitableEventGroup<T>](../AwaitableEventGroup-1.md) * namespace [Microsoft.Coyote.Actors](../AwaitableEventGroup-1.md) * assembly [Microsoft.Coyote.Actors](../../Microsoft.Coyote.Actors.md) ``` -------------------------------- ### List Coyote Command Line Options Source: https://github.com/microsoft/coyote/blob/main/docs/get-started/using-coyote.md Run this command to see all available command-line options for the Coyote tool. ```plain coyote -? ``` -------------------------------- ### SharedCounter.GetValue Method Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Actors.SharedObjects/SharedCounter/GetValue.md Gets the current value of the shared counter. ```APIDOC ## SharedCounter.GetValue Method ### Description Gets the current value of the shared counter. ### Method GET (assumed, as it retrieves a value) ### Endpoint /api/sharedcounter/{counterId}/value (hypothetical endpoint based on method name) ### Parameters #### Query Parameters None explicitly mentioned. ### Request Example (No request body or parameters are typically needed for a simple getter method) ### Response #### Success Response (200) - **value** (integer) - The current value of the shared counter. #### Response Example ```json { "value": 10 } ``` ``` -------------------------------- ### Initialize TestReport with Configuration Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.SystematicTesting/TestReport/TestReport.md Use this constructor to create a new TestReport instance, providing the necessary configuration object. ```csharp public TestReport(Configuration configuration) ``` -------------------------------- ### GET HaltEvent.Instance Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Actors/HaltEvent/Instance.md Retrieves the static instance of the HaltEvent class. ```APIDOC ## GET HaltEvent.Instance ### Description Gets a HaltEvent instance. ### Method GET ### Endpoint Microsoft.Coyote.Actors.HaltEvent.Instance ### Response #### Success Response (200) - **Instance** (HaltEvent) - The static instance of the HaltEvent class. ``` -------------------------------- ### Run the Image Gallery service locally Source: https://github.com/microsoft/coyote/blob/main/docs/tutorials/testing-aspnet-service.md Run the ASP.NET Image Gallery service locally. This requires the Azure Storage Emulator and Azure Cosmos Emulator to be installed and running. Open two console windows for the service and the web front end. ```bash cd ImageGalleryService dotnet run ``` ```bash cd ImageGallery dotnet run ``` -------------------------------- ### Configuration.Create Method Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote/Configuration/Create.md Creates a new configuration with default values. ```APIDOC ## Configuration.Create() ### Description Creates a new configuration with default values. ### Method static ### Endpoint N/A (This is a static method, not an API endpoint) ### Parameters This method does not take any parameters. ### Request Example N/A ### Response #### Success Response (200) - **Configuration** (object) - A new configuration object with default values. #### Response Example N/A (The method returns an object, not a JSON response) ``` -------------------------------- ### AwaitableEventGroup.Task Property Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Actors/AwaitableEventGroup-1/Task.md Gets the task created by this `AwaitableEventGroup`. ```APIDOC ## AwaitableEventGroup.Task Property ### Description Gets the task created by this `AwaitableEventGroup`. ### Method GET ### Endpoint N/A (Property) ### Parameters N/A ### Request Example N/A ### Response #### Success Response (200) - **Task** (Task) - The task created by this `AwaitableEventGroup`. #### Response Example ```csharp public Task Task { get; } ``` ``` -------------------------------- ### Execute TestingEngine.Run Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.SystematicTesting/TestingEngine/Run.md Invokes the testing engine to begin the systematic testing process. ```csharp public void Run() ``` -------------------------------- ### Method: SetLogger Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.SystematicTesting/TestingEngine/SetLogger.md Installs the specified ILogger to log messages during testing. ```APIDOC ## SetLogger ### Description Installs the specified ILogger to log messages during testing. ### Method void ### Parameters - **logger** (ILogger) - Required - The logger instance to be used for recording test messages. ### Request Example ```csharp engine.SetLogger(myLogger); ``` ``` -------------------------------- ### AccountManager Command Line Options Source: https://github.com/microsoft/coyote/blob/main/docs/tutorials/first-concurrency-unit-test.md View available execution modes for the AccountManager binary. ```plain Usage: AccountManager [option] Options: -s Run sequential test without Coyote -c Run concurrent test without Coyote ``` -------------------------------- ### Configuration Constructor Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote/Configuration/Configuration.md Initializes a new instance of the Configuration class. ```APIDOC ## Configuration Constructor ### Description Initializes a new instance of the Configuration class. ### Method Constructor ### Endpoint Microsoft.Coyote.Configuration() ### Request Example protected Configuration() ``` -------------------------------- ### RuntimeProvider.Current Property Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Runtime/RuntimeProvider.md Accesses the runtime installed in the current execution context. ```APIDOC ## GET RuntimeProvider.Current ### Description Retrieves the runtime instance currently installed in the execution context. ### Method GET ### Endpoint Microsoft.Coyote.Runtime.RuntimeProvider.Current ### Response - **ICoyoteRuntime** (object) - The runtime instance associated with the current execution context. ``` -------------------------------- ### Coyote test output statistics with 1000 max-steps Source: https://github.com/microsoft/coyote/blob/main/docs/how-to/liveness-checking.md Example output after increasing the max-steps bound, showing reduced frequency of bound exceedance. ```plain ... Testing statistics: ..... Found 0 bugs. ... Exploration statistics: ..... Explored 40 schedules: 40 fair and 0 unfair. ..... Number of scheduling decisions in fair terminating schedules: 88 (min), 657 (avg), 2411 (max). ..... Exceeded the max-steps bound of '1000' in 27.50% of the fair schedules. ... Elapsed 3.3885497 sec. . Done ``` -------------------------------- ### Define SetupEvent for Client Actor Initialization Source: https://github.com/microsoft/coyote/blob/main/docs/concepts/actors/overview.md Defines a SetupEvent used to pass the Server's ActorId to the Client actor during its initialization. ```csharp class SetupEvent : Event { public readonly ActorId ServerId; public SetupEvent(ActorId server) { this.ServerId = server; } } ``` -------------------------------- ### Actor.Logger Property Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Actors/Actor/Logger.md The logger installed to the runtime. See Logging for more information. ```APIDOC ## Actor.Logger Property ### Description The logger installed to the runtime. ### Remarks See [Logging](/coyote/concepts/actors/logging) for more information. ### See Also * class [Actor](../Actor.md) * namespace [Microsoft.Coyote.Actors](../Actor.md) * assembly [Microsoft.Coyote.Actors](../../Microsoft.Coyote.Actors.md) ``` -------------------------------- ### Project File Setup for Coyote and xUnit Source: https://github.com/microsoft/coyote/blob/main/docs/how-to/unit-testing.md Include these NuGet packages in your .NET project file to enable Coyote testing within an xUnit framework. Ensure you have the correct target framework specified. ```xml net8.0 all runtime; build; native; contentfiles; analyzers; buildtransitive ``` -------------------------------- ### GET IRuntimeExtension.GetCoverageInfo Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Runtime/IRuntimeExtension/GetCoverageInfo.md Retrieves the extended CoverageInfo object from the runtime extension. ```APIDOC ## GET IRuntimeExtension.GetCoverageInfo ### Description Returns the extended CoverageInfo object associated with the runtime extension. ### Method GET ### Endpoint IRuntimeExtension.GetCoverageInfo() ### Response #### Success Response (200) - **CoverageInfo** (object) - The extended coverage information object. ``` -------------------------------- ### ICoyoteRuntime.Logger Property Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Runtime/ICoyoteRuntime/Logger.md Gets or sets an ILogger for logging runtime messages. ```APIDOC ## ICoyoteRuntime.Logger Property ### Description Gets or sets an [`ILogger`](../../Microsoft.Coyote.Logging/ILogger.md) for logging runtime messages. ### Method GET/SET ### Endpoint N/A (Property) ### Parameters N/A ### Request Example N/A ### Response #### Success Response (200) - **Logger** (ILogger) - The logger instance. #### Response Example ```csharp public ILogger Logger { get; set; } ``` ## Remarks See [Logging](/coyote/concepts/actors/logging) for more information. ``` -------------------------------- ### StartAttribute Constructor Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Actors/StateMachine.State.StartAttribute/StartAttribute.md Documentation for the default constructor of the StartAttribute class. ```APIDOC ## StartAttribute Constructor ### Description The default constructor for the StartAttribute class. ### Method Constructor ### Endpoint Microsoft.Coyote.Actors.StateMachine.State.StartAttribute() ### Request Example new StartAttribute(); ``` -------------------------------- ### Configuring Coyote Testing Engine Strategy Source: https://github.com/microsoft/coyote/blob/main/docs/how-to/unit-testing.md Customize the Coyote testing strategy using the `Configuration.Create()` builder pattern. This example sets the prioritization strategy with a specific value. ```csharp var config = Configuration.Create().WithPrioritizationStrategy(false, 10); ``` -------------------------------- ### GET AwaitableEventGroup.IsFaulted Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Actors/AwaitableEventGroup-1/IsFaulted.md Retrieves the fault status of the AwaitableEventGroup task. ```APIDOC ## GET AwaitableEventGroup.IsFaulted ### Description Gets a value that indicates whether the task completed due to an unhandled exception. ### Property Definition `public bool IsFaulted { get; }` ### Namespace Microsoft.Coyote.Actors ### Assembly Microsoft.Coyote.Actors.dll ``` -------------------------------- ### Get Actor.CurrentEventGroup Property Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Actors/Actor/CurrentEventGroup.md This property is an optional argument for CreateActor or SendEvent. ```csharp public EventGroup CurrentEventGroup { get; set; } ``` -------------------------------- ### StartActorAsync Method Signature Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Actors.UnitTesting/ActorTestKit-1/StartActorAsync.md Initializes the actor and returns a task that completes when the actor reaches quiescence. ```csharp public Task StartActorAsync(Event initialEvent = null) ``` -------------------------------- ### Run AccountManager without Coyote Source: https://github.com/microsoft/coyote/blob/main/docs/tutorials/first-concurrency-unit-test.md Execute the compiled binary directly from the samples directory. ```plain cd .\Samples\bin\net8.0 .\AccountManager.exe ``` -------------------------------- ### Configuration.TestingIterations Property Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote/Configuration/TestingIterations.md Gets the number of testing iterations. This property is read-only. ```csharp public uint TestingIterations { get; } ``` -------------------------------- ### Initialize ActorTestKit with Configuration Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Actors.UnitTesting/ActorTestKit-1/ActorTestKit.md Constructs an ActorTestKit instance by providing the required runtime configuration. ```csharp public ActorTestKit(Configuration configuration) ``` -------------------------------- ### Operation.OnStarted Method Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Runtime/Operation/OnStarted.md Notifies that the operation with the specified id has started executing. ```APIDOC ## Operation.OnStarted Method ### Description Notifies that the operation with the specified id has started executing. ### Method static void ### Endpoint N/A (This is a method call, not an API endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp Operation.OnStarted(operationId); ``` ### Response #### Success Response (void) This method does not return a value. #### Response Example N/A ``` -------------------------------- ### StartActorAsync Method Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Actors.UnitTesting/ActorTestKit-1/StartActorAsync.md Initializes the actor and invokes its on-entry handler, returning a task that completes when the actor reaches quiescence. ```APIDOC ## StartActorAsync ### Description Initializes the actor, passes the optional specified event and invokes its on-entry handler, if there is one available. This method returns a task that completes when the actor reaches quiescence. If the actor is a state machine it also transitions the actor to its start state. ### Method public Task StartActorAsync(Event initialEvent = null) ### Parameters #### Path Parameters - **initialEvent** (Event) - Optional - Optional event used during initialization. ### Response - **Task** - Represents the asynchronous operation. ``` -------------------------------- ### Use Q-Learning Strategy in Configuration Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote/Configuration/WithQLearningStrategy.md Call this method to enable the Q-learning exploration strategy. This explicitly disables the default exploration mode. ```csharp public Configuration WithQLearningStrategy() ``` -------------------------------- ### GET TestReport.CoverageInfo Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.SystematicTesting/TestReport/CoverageInfo.md Retrieves the code coverage information associated with a test report. ```APIDOC ## GET TestReport.CoverageInfo ### Description Retrieves the ActorCoverageInfo object containing code coverage metrics for the test execution. ### Method GET ### Endpoint TestReport.CoverageInfo ### Response #### Success Response (200) - **CoverageInfo** (ActorCoverageInfo) - The code coverage information object. ``` -------------------------------- ### Configuration.WithQLearningStrategy Method Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote/Configuration/WithQLearningStrategy.md Updates the configuration to use the Q-learning exploration strategy during systematic testing. Note that explicitly setting this strategy disables the default exploration mode that uses a tuned portfolio of strategies. ```APIDOC ## Configuration.WithQLearningStrategy Method ### Description Updates the configuration to use the Q-learning exploration strategy during systematic testing. ### Method `public Configuration WithQLearningStrategy()` ### Remarks Note that explicitly setting this strategy disables the default exploration mode that uses a tuned portfolio of strategies. ### See Also * class [Configuration](../Configuration.md) * namespace [Microsoft.Coyote](../Configuration.md) * assembly [Microsoft.Coyote](../../Microsoft.Coyote.md) ``` -------------------------------- ### Get MaxOperationGroupingDegree Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.SystematicTesting/TestReport/MaxOperationGroupingDegree.md Retrieves the maximum degree of operation grouping. This property is read-only. ```csharp public int MaxOperationGroupingDegree { get; } ``` -------------------------------- ### Initialize Coyote Runtime and Execute Tests Source: https://github.com/microsoft/coyote/blob/main/docs/tutorials/actors/hello-world.md The `Main` method sets up the Coyote configuration and runtime, attaches a failure handler, and waits for user input to terminate. The `Execute` method, marked with `[Test]`, is called by the `coyote test` tool to create actors. ```csharp public static void Main() { var config = Configuration.Create(); IActorRuntime runtime = RuntimeFactory.Create(config); Execute(runtime); runtime.OnFailure += OnRuntimeFailure; Console.WriteLine("press ENTER to terminate..."); Console.ReadLine(); } ``` ```csharp [Microsoft.Coyote.SystematicTesting.Test] public static void Execute(IActorRuntime runtime) { runtime.CreateActor(typeof(TestActor)); } ``` -------------------------------- ### GET SharedRegister.GetValue Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Actors.SharedObjects/SharedRegister-1/GetValue.md Retrieves the current value stored in the shared register. ```APIDOC ## GET SharedRegister.GetValue ### Description Gets the current value of the register. ### Method GET ### Endpoint SharedRegister.GetValue() ### Response #### Success Response (200) - **value** (T) - The current value stored in the register. ``` -------------------------------- ### Initialize StartAttribute Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Actors/StateMachine.State.StartAttribute/StartAttribute.md The default constructor for the StartAttribute class. ```csharp public StartAttribute() ``` -------------------------------- ### GET GetActorExecutionStatus Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Actors/IActorRuntime/GetActorExecutionStatus.md Retrieves the execution status of an actor using its unique ActorId. ```APIDOC ## GET GetActorExecutionStatus ### Description Returns the execution status of the actor with the specified ActorId. ### Method GET ### Parameters #### Path Parameters - **id** (ActorId) - Required - The id of the actor. ### Return Value - **ActorExecutionStatus** - The execution status of the actor. ### Remarks This method is not thread-safe. ``` -------------------------------- ### AwaitableEventGroup.Task Property Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Actors/AwaitableEventGroup-1/Task.md Gets the task created by this AwaitableEventGroup. This property is read-only. ```csharp public Task Task { get; } ``` -------------------------------- ### Monitor.State.StartAttribute Class Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Specifications/Monitor.State.StartAttribute.md Details regarding the StartAttribute class used for defining monitor entry states. ```APIDOC ## Monitor.State.StartAttribute ### Description Attribute for declaring that a state of a monitor is the start one. ### Definition [AttributeUsage(AttributeTargets.Class)] protected sealed class StartAttribute : Attribute ### Public Members - **StartAttribute()**: The default constructor. ``` -------------------------------- ### Build the Coyote project Source: https://github.com/microsoft/coyote/blob/main/docs/get-started/build-source.md Execute the build script from a Visual Studio 2022 Developer Command Prompt. ```powershell powershell -f Scripts/build.ps1 ``` -------------------------------- ### Get TotalControlledOperations Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.SystematicTesting/TestReport/TotalControlledOperations.md This property returns the total number of controlled operations. It is a read-only integer. ```csharp public int TotalControlledOperations { get; } ``` -------------------------------- ### Get MinOperationGroupingDegree Property Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.SystematicTesting/TestReport/MinOperationGroupingDegree.md Retrieves the minimum degree of operation grouping. This property is read-only. ```csharp public int MinOperationGroupingDegree { get; } ``` -------------------------------- ### Create TestingEngine with Action Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.SystematicTesting/TestingEngine/Create.md Use this overload to create a testing engine with a simple Action delegate. This is suitable for tests that do not require direct access to the runtime. ```csharp public static TestingEngine Create(Configuration configuration, Action test) ``` -------------------------------- ### Get Monitor Current State Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Specifications/Monitor/CurrentState.md Accesses the current state of the monitor. This property is read-only. ```csharp protected Type CurrentState { get; } ``` -------------------------------- ### Operation.PauseUntil Method Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Runtime/Operation/PauseUntil.md Pauses the currently executing operation until the specified condition gets resolved. ```APIDOC ## Operation.PauseUntil Method ### Description Pauses the currently executing operation until the specified condition gets resolved. ### Method static void ### Endpoint N/A (This is a method signature, not an API endpoint) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp // Example usage: Operation.PauseUntil(() => someCondition); ``` ### Response #### Success Response (void) This method does not return a value. #### Response Example N/A ``` -------------------------------- ### Configuration.WithPrioritizationStrategy Method Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote/Configuration/WithPrioritizationStrategy.md Updates the configuration to use the priority-based exploration strategy during systematic testing. ```APIDOC ## Configuration.WithPrioritizationStrategy ### Description Updates the configuration to use the priority-based exploration strategy during systematic testing. Note that explicitly setting this strategy disables the default exploration mode that uses a tuned portfolio of strategies. ### Method C# Method ### Parameters #### Parameters - **isFair** (bool) - Optional - If true, enable liveness checking by using fair scheduling. Defaults to false. - **priorityChangeBound** (uint) - Optional - Upper bound of possible priority changes per test iteration. Defaults to 10. ### Request Example ```csharp var config = Configuration.Create().WithPrioritizationStrategy(isFair: true, priorityChangeBound: 5); ``` ``` -------------------------------- ### Get Coverage Info Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Runtime/IRuntimeExtension/GetCoverageInfo.md Returns the extended CoverageInfo. This method is part of the IRuntimeExtension interface. ```csharp public CoverageInfo GetCoverageInfo() ``` -------------------------------- ### GET SharedDictionary.Count Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Actors.SharedObjects/SharedDictionary-2/Count.md Retrieves the total number of elements contained within the SharedDictionary instance. ```APIDOC ## GET SharedDictionary.Count ### Description Gets the number of elements currently stored in the dictionary. ### Method GET ### Endpoint SharedDictionary.Count ### Response #### Success Response (200) - **Count** (int) - The number of elements in the dictionary. ``` -------------------------------- ### Server state coverage details Source: https://github.com/microsoft/coyote/blob/main/docs/tutorials/actors/raft-mocking.md Example coverage report section for a 'Server' state machine, detailing event coverage, received and sent events, and previous/next states. This helps in understanding state transitions and event handling. ```plain State: Candidate State event coverage: 100.0% Events received: Microsoft.Coyote.Actors.Timers.TimerElapsedEvent, AppendLogEntriesRequestEvent, AppendLogEntriesResponseEvent, VoteRequestEvent, VoteResponseEvent Events sent: AppendLogEntriesResponseEvent, VoteRequestEvent, VoteResponseEvent Previous states: Candidate, Follower Next states: Candidate, Follower, Leader ``` -------------------------------- ### GET GetCurrentActorTypes Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Actors/IActorRuntime/GetCurrentActorTypes.md Retrieves the distinct types of all active actors currently managed by the runtime. ```APIDOC ## GET GetCurrentActorTypes ### Description Returns the distinct types of all active actors currently managed by this runtime. ### Method GET ### Remarks This method is not thread-safe. ### Response #### Success Response (200) - **Return Value** (IEnumerable) - The distinct types of all active actors. ``` -------------------------------- ### Connect to Azure Cosmos DB Source: https://github.com/microsoft/coyote/blob/main/Scripts/Notebooks/AzurePerformanceGraphs.ipynb Establishes a connection to Azure Cosmos DB using provided account URI and key, and creates necessary databases and containers if they do not exist. Ensure COSMOS_ACCOUNT_URI and COSMOS_ACCOUNT_KEY environment variables are set. ```python from azure.cosmos import CosmosClient, PartitionKey import os url = os.environ['COSMOS_ACCOUNT_URI'] key = os.environ['COSMOS_ACCOUNT_KEY'] cosmos_client = CosmosClient(url, credential=key) database = cosmos_client.create_database_if_not_exists('actorperfdb') print('Database actorperfdb created') perfcontainer = database.create_container_if_not_exists(id='actorperfsummary', partition_key=PartitionKey(path='/PartitionKey')) print('Container actorperfsummary opened') commitcontainer = database.create_container_if_not_exists(id='commitlog', partition_key=PartitionKey(path='/PartitionKey')) print('Container commitlog opened') ``` -------------------------------- ### Initialize a non-periodic timer Source: https://github.com/microsoft/coyote/blob/main/docs/concepts/actors/timers.md Starts a non-periodic timer during the actor's initialization phase. ```csharp protected override Task OnInitializeAsync(Event initialEvent) { Console.WriteLine(" Starting a non-periodic timer"); this.StartTimer(TimeSpan.FromSeconds(1)); return base.OnInitializeAsync(initialEvent); } ``` -------------------------------- ### Update Configuration with Specific Unfair and Fair Scheduling Steps Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote/Configuration/WithMaxSchedulingSteps.md This overloaded method allows specifying distinct maximum steps for unfair and fair scheduling. It is recommended to use the simpler overload unless specific control is needed. ```csharp public Configuration WithMaxSchedulingSteps(uint maxUnfairSteps, uint maxFairSteps) ``` -------------------------------- ### ColdAttribute Constructor Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Specifications/Monitor.State.ColdAttribute/ColdAttribute.md The default constructor for the ColdAttribute class. No specific setup or constraints are mentioned. ```csharp public ColdAttribute() ``` -------------------------------- ### Configure binary rewriting with JSON Source: https://github.com/microsoft/coyote/blob/main/docs/concepts/binary-rewriting.md Configuration file structure for rewriting multiple assemblies. ```json { "AssembliesPath": "bin/net8.0", "OutputPath": "bin/net8.0/rewritten", "Assemblies": [ "BoundedBuffer.dll", "MyOtherLibrary.dll", "FooBar123.dll" ] } ``` -------------------------------- ### Initialize SendOptions instance Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Actors/SendOptions/SendOptions.md Constructs a new SendOptions object with optional parameters for mustHandle, assert, and hashedState. ```csharp public SendOptions(bool mustHandle = false, int assert = -1, int hashedState = 0) ``` -------------------------------- ### Send events to a LivenessMonitor Source: https://github.com/microsoft/coyote/blob/main/docs/tutorials/actors/test-failover.md Examples of notifying the monitor when the system enters or exits a busy state. ```csharp this.Monitor(new LivenessMonitor.BusyEvent()); ``` ```csharp this.Monitor(new LivenessMonitor.IdleEvent()); ``` -------------------------------- ### Implement AccountManager.CreateAccount Source: https://github.com/microsoft/coyote/blob/main/docs/tutorials/mocks/mock-dependencies.md A potentially buggy implementation of account creation that checks for existence before creating a row. ```csharp // Returns true if the account is created, else false. public async Task CreateAccount(string accountName, string accountPayload) { if (await this.AccountCollection.DoesRowExist(accountName)) { return false; } return await this.AccountCollection.CreateRow(accountName, accountPayload); } ``` -------------------------------- ### State machine execution output Source: https://github.com/microsoft/coyote/blob/main/docs/concepts/actors/state-machines.md Example console output generated by the state machine during execution. ```plain Program+Client(2) initializing Program+Client(2) sending ping event to server Program+Client(1) initializing Program+Client(1) sending ping event to server Program+Client(3) initializing Program+Client(3) sending ping event to server Server received ping event from Program+Client(2) Server received ping event from Program+Client(1) ``` -------------------------------- ### Test Sequential Account Creation Source: https://github.com/microsoft/coyote/blob/main/docs/tutorials/first-concurrency-unit-test.md Verifies that creating the same account twice results in a failure on the second attempt. ```csharp string accountName = "MyAccount"; string accountPayload = "..."; // Create the account, it should complete successfully and return true. var result = await accountManager.CreateAccount(accountName, accountPayload); Assert.True(result); // Create the same account again. The method should return false this time. result = await accountManager.CreateAccount(accountName, accountPayload); Assert.False(result); } ``` -------------------------------- ### Get NumOfExploredFairPaths Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.SystematicTesting/TestReport/NumOfExploredFairPaths.md Retrieves the number of fair execution paths explored during testing. This property is read-only. ```csharp public int NumOfExploredFairPaths { get; } ``` -------------------------------- ### Start an operation in C# Source: https://github.com/microsoft/coyote/blob/main/docs/ref/Microsoft.Coyote.Runtime/Operation/Start.md Initiates an operation using its unique identifier. Requires the Microsoft.Coyote assembly. ```csharp public static void Start(ulong operationId) ```