private void DestroyMachine(TestMachine machine, bool ignoreError = false) { if (machine == null) { return; } var runner = this.GetProcRunner(); var procSettings = this.CreateProcessSettings(); this.AddArgument(procSettings, "unregistervm"); this.AddArgument(procSettings, $"\"{machine.Name}\""); this.AddArgument(procSettings, "--delete"); var proc = runner.Start(VboxmanageFilePath, procSettings); proc.WaitForExit(); if (proc.GetExitCode() != 0) { var stderr = string.Join("\n", proc.GetStandardError()); if (!ignoreError) { throw new Exception(string.Format("Failed to unregistervm: Error: {0}", stderr)); } } }
private TestMachine DataMachine() { var states = DataStates(); var stateMachine = new TestMachine(states.ToArray(), this); stateMachine.StateChanged += DataSetup; return(stateMachine); }
private void ProgramRun() { TestState[] states = new TestState[] { //new State(); }; var stateMachine = new TestMachine(states, driver); stateMachine.Run(); }
public void return_add_expression() { var builder = new AstBodyBuilder(); var label = builder.NewLabel(); builder.MarkLabel(label); builder.Return( AstFactory.ConstantExpression(19).Plus(23)); var function = new TestFunction(builder.ToBody()); var machine = new TestMachine(); var interpreter = new Interpreter(machine); var result = interpreter.Evaluate(function); Assert.Equal(42u, result); }
private void TryCreateVm(string vmName) { try { this.CreateVm(vmName); } catch (TestCreateVmException ex) { var machine = new TestMachine() { Created = true, HdFile = string.Empty, Name = vmName }; this.HaltMachine(machine, true); Thread.Sleep(3000); this.DestroyMachine(machine, true); var vmFile = VboxHelper.ExistingMachineSettingsFile(ex.ErrorLines); if (!string.IsNullOrWhiteSpace(vmFile)) { var vmFilePath = new FilePath(vmFile); var dirPath = vmFilePath.GetDirectory(); var fs = CakeFixtures.CkFileSystem; var file = fs.GetFile(vmFilePath); if (file.Exists) { file.Delete(); } var dir = fs.GetDirectory(dirPath); if (dir.Exists) { dir.Delete(true); } } this.CreateVm(vmName); } }
public StateMachineAdapter(TState state) { m_machine = new TestMachine <TState, TTrigger, EventArgs>(); m_machine.Start(state); }
public StateConfiguration(TestMachine <TState, TTrigger, EventArgs> machine, TState state) { m_machine = machine; m_state = state; }
public static void Main(string[] args) { TestMachine.TestObserver(); }
public TestVboxHelper(TestMachine machine, DirectoryPath cwd) { this.CurrentTestMachine = machine; this.WorkingDirectory = cwd; }
public void DestroyTestMachine(TestMachine machine = null) { machine = machine ?? this.CurrentTestMachine; this.DestroyMachine(machine, true); }
public void TestInit() { pBox = new ProductBox("products", 40, 20); // name, typs of products, capacity of each product pBox.AddProduct(water, 20); // product, count pBox.AddProduct(soda, 20); pBox.AddProduct(cola, 20); /// 100 x 1p, 50 x 5p, 50 x 10p sBox = new CoinBox(Machine.StoreCoinBox); sBox.AddCoins(one, 100); // coin, count sBox.AddCoins(five, 50); sBox.AddCoins(ten, 50); rBox = new CoinBox(Machine.ReceiveCoinBox); rBox.Clear(); machine = new TestMachine(pBox, rBox, sBox, TestMessenger.Default); machine.Start(); }
public void Run() { TestMachine stateMachine = tester.StateMachine; stateMachine.Run(); }