-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathAutoRunner.cs
More file actions
25 lines (22 loc) · 930 Bytes
/
AutoRunner.cs
File metadata and controls
25 lines (22 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using ActualLab.Resilience;
using static System.Console;
namespace Samples.HelloCart;
public static class AutoRunner
{
public static async Task Run(AppBase app, CancellationToken cancellationToken = default)
{
ChaosMaker.Default.TryEnable();
var productService = app.ClientServices.GetRequiredService<IProductService>();
var commander = app.ClientServices.Commander();
var rnd = new Random(10);
for (var i = 0;; i++) {
var productId = app.ExistingProducts[rnd.Next(app.ExistingProducts.Length)].Id;
var product = await productService.Get(productId, cancellationToken);
var price = rnd.Next(10);
var command = new EditCommand<Product>(product! with { Price = price });
WriteLine(command);
_ = commander.Run(command, cancellationToken);
await Task.Delay(500, cancellationToken);
}
}
}