How to use OnInitializeAsync method of Microsoft.Coyote.Actors.BugFinding.Tests.OnHaltTests class

Best Coyote code snippet using Microsoft.Coyote.Actors.BugFinding.Tests.OnHaltTests.OnInitializeAsync

OnHaltTests.cs

Source: OnHaltTests.cs Github

copy

Full Screen

...23 }24 }25 private class A1 : Actor26 {27 protected override Task OnInitializeAsync(Event initialEvent)28 {29 this.SendEvent(this.Id, HaltEvent.Instance);30 return Task.CompletedTask;31 }32 protected override Task OnHaltAsync(Event e)33 {34 this.Assert(false, "Reached test assertion.");35 return Task.CompletedTask;36 }37 }38 [Fact(Timeout = 5000)]39 public void TestOnHaltAsyncAfterSendInActor()40 {41 this.TestWithError(r =>42 {43 r.CreateActor(typeof(A1));44 },45 expectedError: "Reached test assertion.",46 replay: true);47 }48 private class M1 : StateMachine49 {50 [Start]51 [OnEntry(nameof(InitOnEntry))]52 private class Init : State53 {54 }55 private void InitOnEntry()56 {57 this.SendEvent(this.Id, HaltEvent.Instance);58 }59 protected override Task OnHaltAsync(Event e)60 {61 this.Assert(false, "Reached test assertion.");62 return Task.CompletedTask;63 }64 }65 [Fact(Timeout = 5000)]66 public void TestOnHaltAsyncAfterSendInStateMachine()67 {68 this.TestWithError(r =>69 {70 r.CreateActor(typeof(M1));71 },72 expectedError: "Reached test assertion.",73 replay: true);74 }75 private class M2 : StateMachine76 {77 [Start]78 [OnEntry(nameof(InitOnEntry))]79 private class Init : State80 {81 }82 private void InitOnEntry() => this.RaiseHaltEvent();83 protected override Task OnHaltAsync(Event e)84 {85 this.Assert(false, "Reached test assertion.");86 return Task.CompletedTask;87 }88 }89 [Fact(Timeout = 5000)]90 public void TestOnHaltAsyncAfterRaiseInStateMachine()91 {92 this.TestWithError(r =>93 {94 r.CreateActor(typeof(M2));95 },96 expectedError: "Reached test assertion.",97 replay: true);98 }99 private class A3 : Actor100 {101 protected override Task OnInitializeAsync(Event initialEvent)102 {103 this.SendEvent(this.Id, HaltEvent.Instance);104 return Task.CompletedTask;105 }106 protected override async Task OnHaltAsync(Event e)107 {108 await this.ReceiveEventAsync(typeof(Event));109 }110 }111 [Fact(Timeout = 5000)]112 public void TestOnHaltAsyncWithReceiveInActor()113 {114 this.TestWithError(r =>115 {116 r.CreateActor(typeof(A3));117 },118 expectedError: "A3() invoked ReceiveEventAsync while halting.",119 replay: true);120 }121 private class M3 : StateMachine122 {123 [Start]124 [OnEntry(nameof(InitOnEntry))]125 private class Init : State126 {127 }128 private void InitOnEntry() => this.RaiseHaltEvent();129 protected override async Task OnHaltAsync(Event e)130 {131 await this.ReceiveEventAsync(typeof(Event));132 }133 }134 [Fact(Timeout = 5000)]135 public void TestOnHaltAsyncWithReceiveInStateMachine()136 {137 this.TestWithError(r =>138 {139 r.CreateActor(typeof(M3));140 },141 expectedError: "M3() invoked ReceiveEventAsync while halting.",142 replay: true);143 }144 private class Dummy : StateMachine145 {146 [Start]147 [OnEntry(nameof(InitOnEntry))]148 private class Init : State149 {150 }151 private void InitOnEntry() => this.RaiseHaltEvent();152 }153 private class M4Receiver : StateMachine154 {155 [Start]156 [IgnoreEvents(typeof(E))]157 private class Init : State158 {159 }160 }161 private class A4Sender : Actor162 {163 private ActorId Receiver;164 protected override Task OnInitializeAsync(Event initialEvent)165 {166 this.Receiver = (initialEvent as E).Id;167 this.SendEvent(this.Id, HaltEvent.Instance);168 return Task.CompletedTask;169 }170 protected override Task OnHaltAsync(Event e)171 {172 /​/​ No-ops but no failure.173 this.SendEvent(this.Receiver, new E());174 this.RandomBoolean();175 this.Assert(true);176 this.CreateActor(typeof(Dummy));177 return Task.CompletedTask;178 }...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Get A Seamless Digital Experience With #LambdaTestYourBusiness????

The holidays are just around the corner, and with Christmas and New Year celebrations coming up, everyone is busy preparing for the festivities! And during this busy time of year, LambdaTest also prepped something special for our beloved developers and testers – #LambdaTestYourBusiness

How to Position Your Team for Success in Estimation

Estimates are critical if you want to be successful with projects. If you begin with a bad estimating approach, the project will almost certainly fail. To produce a much more promising estimate, direct each estimation-process issue toward a repeatable standard process. A smart approach reduces the degree of uncertainty. When dealing with presales phases, having the most precise estimation findings can assist you to deal with the project plan. This also helps the process to function more successfully, especially when faced with tight schedules and the danger of deviation.

Best 23 Web Design Trends To Follow In 2023

Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.

Why does DevOps recommend shift-left testing principles?

Companies are using DevOps to quickly respond to changing market dynamics and customer requirements.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful