MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / test

Method test

modules/module-test-cs/Lib.cs:307–407  ·  view source on GitHub ↗
(ReducerContext ctx, TestAlias arg, TestB arg2, TestC arg3, TestF arg4)

Source from the content-addressed store, hash-verified

305 }
306
307 [Reducer]
308 public static void test(ReducerContext ctx, TestAlias arg, TestB arg2, TestC arg3, TestF arg4)
309 {
310 Log.Info("BEGIN");
311 Log.Info($"sender: {ctx.Sender}");
312 Log.Info($"timestamp: {ctx.Timestamp}");
313 Log.Info($"bar: {arg2.foo}");
314
315 // Handle TestC (a simple enum).
316 switch (arg3)
317 {
318 case TestC.Foo:
319 Log.Info("Foo");
320 break;
321 case TestC.Bar:
322 Log.Info("Bar");
323 break;
324 }
325
326 // Handle TestF (a tagged enum). We pattern‐match on its concrete types.
327 switch (arg4)
328 {
329 case TestF.Foo _:
330 Log.Info("Foo");
331 break;
332 case TestF.Bar _:
333 Log.Info("Bar");
334 break;
335 case TestF.Baz fb:
336 Log.Info(fb.Baz_.value);
337 break;
338 }
339
340 // Insert 1000 rows into the test_a table.
341 for (uint i = 0; i < 1000; i++)
342 {
343 ctx.Db.test_a.Insert(new TestA
344 {
345 x = i + arg.x,
346 y = i + arg.y,
347 z = "Yo"
348 });
349 }
350
351 var rowCountBeforeDelete = ctx.Db.test_a.Count;
352 Log.Info($"Row count before delete: {rowCountBeforeDelete}");
353
354 ulong numDeleted = 0;
355 // Delete rows using the "foo" index (from 5 up to, but not including, 10).
356 for (uint row = 5; row < 10; row++)
357 {
358 numDeleted += ctx.Db.test_a.foo.Delete(row);
359 }
360
361 var rowCountAfterDelete = ctx.Db.test_a.Count;
362
363 if (rowCountBeforeDelete != rowCountAfterDelete + numDeleted)
364 {

Callers 15

parseGradingFileFunction · 0.80
countLinesFunction · 0.80
index.tsFile · 0.80
ensureSchemaFunction · 0.80
parseStdbUrlFunction · 0.80
getSqlstateFunction · 0.80
parseMoneyFunction · 0.80
escapeIdentFunction · 0.80
constructorMethod · 0.80
view_handle_no_iterFunction · 0.80
view_handle_no_insertFunction · 0.80

Calls 7

InfoMethod · 0.45
InsertMethod · 0.45
DeleteMethod · 0.45
ErrorMethod · 0.45
CountMethod · 0.45
WhereMethod · 0.45
IterMethod · 0.45

Tested by 7

view_handle_no_iterFunction · 0.64
view_handle_no_insertFunction · 0.64
view_handle_no_deleteFunction · 0.64