示例#1
0
        public void TestEventInheritanceRun()
        {
            var tcs     = new TaskCompletionSource <bool>();
            var runtime = new StateMachineRuntime();
            var a       = runtime.CreateMachine(typeof(A), null, new A.Configure(tcs), null);

            runtime.SendEvent(a, new A.E3());
            runtime.SendEvent(a, new E1());
            runtime.SendEvent(a, new E2());
            Assert.True(tcs.Task.Wait(2000), "Test timed out");
        }
示例#2
0
        public void SendMessages()
        {
            var tcs = new TaskCompletionSource <bool>();

            var runtime = new StateMachineRuntime();

            runtime.CreateMachine(typeof(Server), null,
                                  new Server.Configure(tcs, this.Clients, this.EventsPerClient),
                                  null);

            tcs.Task.Wait();
        }
示例#3
0
        public void CreateMachines()
        {
            var runtime = new StateMachineRuntime();

            var tcs = new TaskCompletionSource <bool>();

            Node.Configure evt = new Node.Configure(tcs, Size);

            for (int idx = 0; idx < Size; idx++)
            {
                runtime.CreateMachine(typeof(Node), null, evt, null);
            }

            tcs.Task.Wait();
        }
示例#4
0
        public void RunWithLogger()
        {
            var configuration = PSharp.Configuration.Create().WithVerbosityEnabled(0);
            var runtime       = new StateMachineRuntime(configuration);
            ConcurrentQueue <MachineId> machines = new ConcurrentQueue <MachineId>();

            Parallel.For(0, Clients, index =>
            {
                machines.Enqueue(runtime.CreateMachine(typeof(SimpleMachine), new SetContextMessage(runtime)));
            });

            foreach (var machine in machines)
            {
                runtime.SendEvent(machine, new Halt());
            }
        }