示例#1
0
        public async void StateMachineTransitionsCorrectly()
        {
            // TODO(HonzaS): Rewrite this test to take advantage of the control methods being async.
            ICoreLink coreLink = new DummyCoreLink();

            var coreController = new CoreController(coreLink, keepaliveIntervalMs: 20);

            var coreProxy = new CoreProxy(coreController, m_modelUpdater);

            Assert.Equal(CoreState.Disconnected, coreProxy.State);

            // Simulate the core sending first state information.
            coreProxy.State = CoreState.Empty;

            await coreProxy.LoadBlueprintAsync("{}");

            Assert.Equal(CoreState.Paused, coreProxy.State);

            await coreProxy.RunAsync();

            Assert.Equal(CoreState.Running, coreProxy.State);

            await coreProxy.PauseAsync();

            Assert.Equal(CoreState.Paused, coreProxy.State);

            await coreProxy.ClearAsync();

            Assert.Equal(CoreState.Empty, coreProxy.State);

            // Test direct Clear from a Running state.
            await coreProxy.LoadBlueprintAsync("{}");

            await coreProxy.RunAsync();

            await coreProxy.ClearAsync();

            await coreProxy.ShutdownAsync();

            Assert.Equal(CoreState.ShuttingDown, coreProxy.State);
        }
示例#2
0
        public async void SimulationHandlesErrors()
        {
            var coreLink = new DummyCoreLink {
                Fail = true
            };

            var coreController = new CoreController(coreLink);

            var coreProxy = new CoreProxy(coreController, m_modelUpdater);

            Assert.Equal(CoreState.Disconnected, coreProxy.State);

            coreProxy.State = CoreState.Empty;

            await Assert.ThrowsAsync <RemoteCoreException>(() => coreProxy.LoadBlueprintAsync("{}"));
        }