-
Notifications
You must be signed in to change notification settings - Fork 0
/
SystemTest.cs
56 lines (45 loc) · 1.36 KB
/
SystemTest.cs
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using revecs.Core;
using revecs.Systems;
using revtask.Core;
using revtask.OpportunistJobRunner;
using Xunit;
using Xunit.Abstractions;
namespace revecs.Tests;
public class SystemTest : TestBase
{
public SystemTest(ITestOutputHelper output) : base(output)
{
}
[Fact]
public void TestSimpleSystem()
{
using var world = new RevolutionWorld();
using var runner = new OpportunistJobRunner(1f);
var systemGroup = new SystemGroup(world);
systemGroup.Add(new MySystem());
runner.CompleteBatch(systemGroup.Schedule(runner));
}
public class MySystem : ISystem
{
public bool Create(SystemHandle systemHandle, RevolutionWorld world)
{
return true;
}
public void PreQueue(SystemHandle systemHandle, RevolutionWorld world)
{
}
public JobRequest Queue(SystemHandle systemHandle, RevolutionWorld world, IJobRunner runner)
{
Console.WriteLine($"Queuing with handle {systemHandle}");
return runner.Queue(new Job());
}
struct Job : IJob
{
public int SetupJob(JobSetupInfo info) => 1;
public void Execute(IJobRunner runner, JobExecuteInfo info)
{
Console.WriteLine("Hello World!");
}
}
}
}