Пример #1
0
        private void Init(IUpdateManager updateManager)
        {
            AppDomain.CurrentDomain.AssemblyResolve += AssemblyHelper.CurrentDomain_AssemblyResolve;

            Controller = new DynamoController("None", updateManager,
                                              new DefaultWatchHandler(), new PreferenceSettings());
            DynamoController.IsTestMode     = true;
            Controller.DynamoViewModel      = new DynamoViewModel(Controller, null);
            Controller.VisualizationManager = new VisualizationManager();

            //create the view
            Ui = new DynamoView {
                DataContext = Controller.DynamoViewModel
            };
            Vm = Controller.DynamoViewModel;
            Controller.UIDispatcher = Ui.Dispatcher;
            Ui.Show();

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());

            string tempPath = Path.GetTempPath();

            TempFolder = Path.Combine(tempPath, "dynamoTmp");

            if (!Directory.Exists(TempFolder))
            {
                Directory.CreateDirectory(TempFolder);
            }
            else
            {
                DynamoTestUI.EmptyTempFolder(TempFolder);
            }
        }
Пример #2
0
        protected void RunCommandsFromFile(string commandFileName,
                                           bool autoRun = false, CommandCallback commandCallback = null)
        {
            string commandFilePath = DynamoTestUI.GetTestDirectory(ExecutingDirectory);

            commandFilePath = Path.Combine(commandFilePath, @"core\recorded\");
            commandFilePath = Path.Combine(commandFilePath, commandFileName);

            if (this.Controller != null)
            {
                var message = "Multiple DynamoController detected!";
                throw new InvalidOperationException(message);
            }

            // Create the controller to run alongside the view.
            this.Controller = DynamoController.MakeSandbox(commandFilePath);
            var controller = this.Controller;

            controller.DynamoViewModel.DynamicRunEnabled = autoRun;
            DynamoController.IsTestMode = true;

            RegisterCommandCallback(commandCallback);

            // Create the view.
            var dynamoView = new DynamoView();

            dynamoView.DataContext  = controller.DynamoViewModel;
            controller.UIDispatcher = dynamoView.Dispatcher;
            dynamoView.ShowDialog();

            Assert.IsNotNull(controller);
            Assert.IsNotNull(controller.DynamoModel);
            Assert.IsNotNull(controller.DynamoModel.CurrentWorkspace);
            workspace          = controller.DynamoModel.CurrentWorkspace;
            workspaceViewModel = controller.DynamoViewModel.CurrentSpaceViewModel;
        }