public async Task StartVmDoesNotInitializesSpectrumVmAfterPause()
        {
            // --- Arrange
            var vm = new MachineViewModel
            {
                ClockProvider = new ClockProvider(),
                RomProvider   = new ResourceRomProvider()
            };

            MakeSyncContext();
            vm.StartVmCommand.Execute(null);
            var before = vm.SpectrumVm;

            vm.PauseVmCommand.Execute(null);
            await vm.RunnerTask;
            MachineStateChangedMessage messageReceived = null;

            Messenger.Default.Register <MachineStateChangedMessage>(this,
                                                                    msg => { messageReceived = msg; });

            // --- Act
            MakeSyncContext();
            vm.StartVmCommand.Execute(null);

            // --- Assert
            before.ShouldNotBeNull();
            vm.SpectrumVm.ShouldBeSameAs(before);
            vm.VmState.ShouldBe(VmState.Running);
            vm.RunnerTask.ShouldNotBeNull();
            messageReceived.NewState.ShouldBe(VmState.Running);
        }
        public void StartDebugVmInitializesSpectrumVmFirstTime()
        {
            // --- Arrange
            var vm = new MachineViewModel
            {
                ClockProvider = new ClockProvider(),
                RomProvider   = new ResourceRomProvider()
            };
            var before = vm.SpectrumVm;
            MachineStateChangedMessage messageReceived = null;

            Messenger.Default.Register <MachineStateChangedMessage>(this,
                                                                    msg => { messageReceived = msg; });

            // --- Act
            MakeSyncContext();
            vm.StartDebugVmCommand.Execute(null);

            // --- Assert
            before.ShouldBeNull();
            vm.SpectrumVm.ShouldNotBeNull();
            vm.VmState.ShouldBe(VmState.Running);
            vm.RunsInDebugMode.ShouldBeTrue();
            vm.RunnerTask.ShouldNotBeNull();
            messageReceived.NewState.ShouldBe(VmState.Running);
        }
        public async Task ResetVmIgnoresStoppedVm()
        {
            // --- Arrange
            var vm = new MachineViewModel
            {
                ClockProvider = new ClockProvider(),
                RomProvider   = new ResourceRomProvider()
            };

            MakeSyncContext();
            vm.StartVmCommand.Execute(null);
            vm.StopVmCommand.Execute(null);
            await vm.RunnerTask;
            MachineStateChangedMessage messageReceived = null;

            Messenger.Default.Register <MachineStateChangedMessage>(this,
                                                                    msg => { messageReceived = msg; });

            // --- Act
            vm.ResetVmCommand.Execute(null);

            // --- Assert
            vm.VmState.ShouldBe(VmState.Stopped);
            messageReceived.ShouldBeNull();
        }
        public void ResetVmWorksWithRunningVm()
        {
            // --- Arrange
            var vm = new MachineViewModel
            {
                ClockProvider = new ClockProvider(),
                RomProvider   = new ResourceRomProvider()
            };

            MakeSyncContext();
            vm.StartVmCommand.Execute(null);
            MachineStateChangedMessage messageReceived = null;

            Messenger.Default.Register <MachineStateChangedMessage>(this,
                                                                    msg => { messageReceived = msg; });
            var before = vm.SpectrumVm;

            // --- Act
            vm.ResetVmCommand.Execute(null);

            // --- Assert
            vm.SpectrumVm.ShouldNotBeNull();
            vm.SpectrumVm.ShouldBeSameAs(before);
            vm.VmState.ShouldBe(VmState.Running);
            vm.RunnerTask.ShouldNotBeNull();
            messageReceived.ShouldBeNull();
        }
예제 #5
0
        /// <summary>
        /// Set the machnine status
        /// </summary>
        protected override void OnVmStateChanged(MachineStateChangedMessage msg)
        {
            base.OnVmStateChanged(msg);

            // --- We refresh all lines whenever the machnine is newly started...
            if ((msg.OldState == VmState.None || msg.OldState == VmState.Stopped) &&
                msg.NewState == VmState.Running)
            {
                InitMemoryLines();
                RefreshMemoryLines();
            }
            // --- ... or paused.
            else if (VmPaused)
            {
                RefreshMemoryLines();
            }
            // --- We clear the memory contents as the virtual machine is stopped.
            else if (VmStopped)
            {
                MemoryLines.Clear();
            }
        }
        public void ResetVmIgnoresNotStartedVm()
        {
            // --- Arrange
            var vm = new MachineViewModel
            {
                ClockProvider = new ClockProvider(),
                RomProvider   = new ResourceRomProvider()
            };
            MachineStateChangedMessage messageReceived = null;

            Messenger.Default.Register <MachineStateChangedMessage>(this,
                                                                    msg => { messageReceived = msg; });

            // --- Act
            vm.ResetVmCommand.Execute(null);

            // --- Assert
            vm.SpectrumVm.ShouldBeNull();
            vm.VmState.ShouldBe(VmState.None);
            vm.RunnerTask.ShouldBeNull();
            messageReceived.ShouldBeNull();
        }
예제 #7
0
 /// <summary>
 /// Simply relays the messages to controls
 /// </summary>
 private void OnVmStateChanged(MachineStateChangedMessage msg)
 {
     MessengerInstance.Send(new VmStateChangedMessage(msg.OldState, msg.NewState));
 }