Esempio n. 1
0
        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));
                }
            }
        }
Esempio n. 2
0
        private TestMachine DataMachine()
        {
            var states       = DataStates();
            var stateMachine = new TestMachine(states.ToArray(), this);

            stateMachine.StateChanged += DataSetup;
            return(stateMachine);
        }
Esempio n. 3
0
        private void ProgramRun()
        {
            TestState[] states = new TestState[]
            {
                //new State();
            };
            var stateMachine = new TestMachine(states, driver);

            stateMachine.Run();
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
            }
        }
Esempio n. 6
0
 public StateMachineAdapter(TState state)
 {
     m_machine = new TestMachine <TState, TTrigger, EventArgs>();
     m_machine.Start(state);
 }
Esempio n. 7
0
 public StateConfiguration(TestMachine <TState, TTrigger, EventArgs> machine, TState state)
 {
     m_machine = machine;
     m_state   = state;
 }
Esempio n. 8
0
 public static void Main(string[] args)
 {
     TestMachine.TestObserver();
 }
Esempio n. 9
0
 public TestVboxHelper(TestMachine machine, DirectoryPath cwd)
 {
     this.CurrentTestMachine = machine;
     this.WorkingDirectory   = cwd;
 }
Esempio n. 10
0
        public void DestroyTestMachine(TestMachine machine = null)
        {
            machine = machine ?? this.CurrentTestMachine;

            this.DestroyMachine(machine, true);
        }
Esempio n. 11
0
        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();
        }
Esempio n. 12
0
        public void Run()
        {
            TestMachine stateMachine = tester.StateMachine;

            stateMachine.Run();
        }