Exemple #1
0
        private void RestartTestSetup()
        {
            // Shutdown Dynamo and restart it
            View.Close();
            View = null;

            if (ViewModel != null)
            {
                ViewModel.Model.ShutDown(false);
                ViewModel = null;
            }

            // Setup Temp PreferenceSetting Location for testing
            PreferenceSettings.DYNAMO_TEST_PATH = Path.Combine(TempFolder, "UserPreferenceTest.xml");

            Model = DynamoModel.Start(
                new DynamoModel.StartConfiguration()
            {
                StartInTestMode = true
            });

            ViewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                DynamoModel = Model
            });

            //create the view
            View = new DynamoView(ViewModel);
            View.Show();

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
        }
Exemple #2
0
        public void Init()
        {
            storageExt    = new Mock <IExtensionStorageAccess>();
            extensionMock = storageExt.As <IExtension>();

            storageExt.SetupGet(x => x.UniqueId).Returns(MOCK_EXTENSION_GUID);
            storageExt.SetupGet(x => x.Name).Returns(MOCK_EXTENSION_NAME);

            extensionMock.SetupGet(x => x.UniqueId).Returns(MOCK_EXTENSION_GUID);
            extensionMock.SetupGet(x => x.Name).Returns(MOCK_EXTENSION_NAME);

            model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
            {
                StartInTestMode = true,
                Extensions      = new List <IExtension> {
                    extensionMock.Object
                },
                ProcessMode = TaskProcessMode.Synchronous
            });

            extensionManager = model.ExtensionManager as ExtensionManager;

            // Make sure events that the storageExt mock uses are not null.
            model.WorkspaceSaving += delegate { };
            model.WorkspaceOpened += delegate { };
        }
Exemple #3
0
        private static void MakeStandaloneAndRun(string commandFilePath, out DynamoViewModel viewModel)
        {
            var geometryFactoryPath = string.Empty;
            var preloaderLocation   = string.Empty;

            PreloadShapeManager(ref geometryFactoryPath, ref preloaderLocation);

            DynamoModel.RequestMigrationStatusDialog += MigrationStatusDialogRequested;

            var model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
            {
                PathResolver        = new PathResolver(preloaderLocation),
                GeometryFactoryPath = geometryFactoryPath
            });

            viewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                CommandFilePath = commandFilePath,
                DynamoModel     = model
            });

            var view = new DynamoView(viewModel);

            view.Loaded += (sender, args) => CloseMigrationWindow();

            var app = new Application();

            app.Run(view);

            DynamoModel.RequestMigrationStatusDialog -= MigrationStatusDialogRequested;
        }
Exemple #4
0
        private static void MakeStandaloneAndRun(string commandFilePath, ref DynamoViewModel viewModel)
        {
            DynamoPathManager.Instance.InitializeCore(
                Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

            DynamoPathManager.PreloadAsmLibraries(DynamoPathManager.Instance);

            var model = DynamoModel.Start(
                new DynamoModel.StartConfiguration()
            {
                Preferences = PreferenceSettings.Load()
            });

            viewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                CommandFilePath = commandFilePath,
                DynamoModel     = model
            });

            var view = new DynamoView(viewModel);

            var app = new Application();

            app.Run(view);
        }
Exemple #5
0
        public void Init()
        {
            mockExtension = new Mock <LinterExtensionBase>()
            {
                CallBase = true
            };
            mockRule = new Mock <NodeLinterRule> {
                CallBase = true
            };

            // Setup mock rule
            mockRule.Setup(r => r.Id).Returns(MOCK_RULE_ID);

            // Setup mock LinterExtension
            mockExtension.Setup(e => e.UniqueId).Returns(MOCK_GUID);
            mockExtension.Setup(e => e.Name).Returns(MOCK_Name);

            model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
            {
                StartInTestMode = true,
                Extensions      = new List <IExtension> {
                    mockExtension.Object
                },
                ProcessMode = TaskProcessMode.Synchronous
            });
        }
        private void Init()
        {
            AppDomain.CurrentDomain.AssemblyResolve += AssemblyHelper.ResolveAssembly;

            var corePath =
                Path.GetFullPath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

            Model = DynamoModel.Start(
                new DynamoModel.StartConfiguration()
            {
                StartInTestMode = true,
                DynamoCorePath  = corePath
            });

            ViewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                DynamoModel = Model
            });

            //create the view
            View = new DynamoView(ViewModel);
            View.Show();

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
            CreateTemporaryFolder();
        }
Exemple #7
0
        public virtual void Start()
        {
            var assemblyPath = Assembly.GetExecutingAssembly().Location;

            preloader = new Preloader(Path.GetDirectoryName(assemblyPath));
            preloader.Preload();
            CreateTemporaryFolder();

            // Setup Temp PreferenceSetting Location for testing
            PreferenceSettings.DynamoTestPath = Path.Combine(TempFolder, "UserPreferenceTest.xml");

            Model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
            {
                StartInTestMode     = true,
                GeometryFactoryPath = preloader.GeometryFactoryPath
            });

            ViewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                DynamoModel = Model
            });

            //create the view
            View = new DynamoView(ViewModel);
            View.Show();

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
        }
Exemple #8
0
        private static void MakeStandaloneAndRun(string commandFilePath, out DynamoViewModel viewModel)
        {
            var geometryFactoryPath = string.Empty;
            var preloaderLocation   = string.Empty;

            PreloadShapeManager(ref geometryFactoryPath, ref preloaderLocation);

            // TODO(PATHMANAGER): Do we really libg_xxx folder on resolution path?
            // If not, PathResolver will be completely redundant so please remove it.
            var pathResolver = new PathResolver(preloaderLocation);

            var model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
            {
                PathResolver        = pathResolver,
                GeometryFactoryPath = geometryFactoryPath
            });

            viewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                CommandFilePath = commandFilePath,
                DynamoModel     = model
            });

            var view = new DynamoView(viewModel);

            var app = new Application();

            app.Run(view);
        }
Exemple #9
0
        private void RestartTestSetupWithNewSettings(Dynamo.Models.DynamoModel.IStartConfiguration configuration, bool startInTestMode)
        {
            // Shutdown Dynamo and restart it
            View.Close();
            View = null;

            if (ViewModel != null)
            {
                var shutdownParams = new DynamoViewModel.ShutdownParams(
                    shutdownHost: false, allowCancellation: false);

                ViewModel.PerformShutdownSequence(shutdownParams);
                ViewModel = null;
            }

            Model = DynamoModel.Start(configuration);

            ViewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                DynamoModel = Model
            });

            var expectedState = startInTestMode
                ? DynamoModel.DynamoModelState.StartedUIless
                : DynamoModel.DynamoModelState.StartedUI;

            Assert.AreEqual(ViewModel.Model.State, expectedState);

            //create the view
            View = new DynamoView(ViewModel);
            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
        }
Exemple #10
0
        public virtual void Start()
        {
            DynamoPathManager.Instance.InitializeCore(
                Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

            DynamoPathManager.PreloadAsmLibraries(DynamoPathManager.Instance);

            AppDomain.CurrentDomain.AssemblyResolve += AssemblyHelper.ResolveAssembly;
            CreateTemporaryFolder();

            // Setup Temp PreferenceSetting Location for testing
            PreferenceSettings.DynamoTestPath = Path.Combine(TempFolder, "UserPreferenceTest.xml");

            Model = DynamoModel.Start(
                new DynamoModel.StartConfiguration()
            {
                StartInTestMode = true
            });

            ViewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                DynamoModel = Model
            });

            //create the view
            View = new DynamoView(ViewModel);
            View.Show();

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
        }
Exemple #11
0
        protected virtual void StartDynamo(TestSessionConfiguration testConfig)
        {
            preloader = new Preloader(testConfig.DynamoCorePath, testConfig.RequestedLibraryVersion);
            preloader.Preload();

            Model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
            {
                StartInTestMode     = true,
                PathResolver        = pathResolver,
                GeometryFactoryPath = preloader.GeometryFactoryPath
            });

            ViewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                DynamoModel = Model
            });

            //create the view
            View = new DynamoView(ViewModel);
            View.Show();

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
        }
Exemple #12
0
        protected override void StartDynamo(TestSessionConfiguration testConfig)
        {
            // Add Dynamo Core location to the PATH system environment variable.
            // This is to make sure dependencies(e.g.Helix assemblies) can be located.
            var path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.Process) + ";" + testConfig.DynamoCorePath;

            Environment.SetEnvironmentVariable("Path", path, EnvironmentVariableTarget.Process);

            var preloader = new Preloader(testConfig.DynamoCorePath, new[] { testConfig.RequestedLibraryVersion2 });

            preloader.Preload();

            var preloadedLibraries = new List <string>();

            GetLibrariesToPreload(preloadedLibraries);

            if (preloadedLibraries.Any())
            {
                if (pathResolver == null)
                {
                    pathResolver = new TestPathResolver();
                }

                var pr = pathResolver as TestPathResolver;
                foreach (var preloadedLibrary in preloadedLibraries.Distinct())
                {
                    pr.AddPreloadLibraryPath(preloadedLibrary);
                }
            }

            Model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
            {
                StartInTestMode     = true,
                PathResolver        = pathResolver,
                GeometryFactoryPath = preloader.GeometryFactoryPath,
                UpdateManager       = this.UpdateManager,
                ProcessMode         = TaskProcessMode.Synchronous
            });

            Model.EvaluationCompleted += Model_EvaluationCompleted;

            ViewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                DynamoModel      = Model,
                Watch3DViewModel =
                    HelixWatch3DViewModel.TryCreateHelixWatch3DViewModel(
                        null,
                        new Watch3DViewModelStartupParams(Model),
                        Model.Logger)
            });

            //create the view
            View = new DynamoView(ViewModel);
            View.Show();

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
        }
Exemple #13
0
        protected void StartDynamo()
        {
            var assemblyPath = Assembly.GetExecutingAssembly().Location;

            preloader = new Preloader(Path.GetDirectoryName(assemblyPath));
            preloader.Preload();

            TestPathResolver pathResolver = null;
            var preloadedLibraries        = new List <string>();

            GetLibrariesToPreload(preloadedLibraries);

            if (preloadedLibraries.Any())
            {
                // Only when any library needs preloading will a path resolver be
                // created, otherwise DynamoModel gets created without preloading
                // any library.
                //

                var pathResolverParams = new TestPathResolverParams()
                {
                    UserDataRootFolder   = GetUserUserDataRootFolder(),
                    CommonDataRootFolder = GetCommonDataRootFolder()
                };

                pathResolver = new TestPathResolver(pathResolverParams);
                foreach (var preloadedLibrary in preloadedLibraries.Distinct())
                {
                    pathResolver.AddPreloadLibraryPath(preloadedLibrary);
                }
            }

            var model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
            {
                PathResolver        = pathResolver,
                StartInTestMode     = true,
                GeometryFactoryPath = preloader.GeometryFactoryPath,
                ProcessMode         = TaskProcessMode.Synchronous
            });

            var watch3DViewParams = new Watch3DViewModelStartupParams(model);

            this.ViewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                DynamoModel      = model,
                Watch3DViewModel = new DefaultWatch3DViewModel(null, watch3DViewParams)
            });

            Assert.AreEqual(ViewModel.Model.State, DynamoModel.DynamoModelState.StartedUIless);

            this.ViewModel.RequestUserSaveWorkflow += RequestUserSaveWorkflow;
        }
Exemple #14
0
        //public void SetupDynamo(out DynamoViewModel viewModel)
        public void SetupDynamo( )
        {
            SubscribeAssemblyResolvingEvent();
            UpdateSystemPathForProcess();

            PreloadDynamoCoreDlls();
            var corePath         = DynamoCorePath;
            var dynamoMayaExeLoc = Assembly.GetExecutingAssembly().Location;
            var dynamoMayaRoot   = Path.GetDirectoryName(dynamoMayaExeLoc);


            var userDataFolder = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                "Dynamo", "Dynamo Core");
            var commonDataFolder = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
                "Dynamo", "Dynamo Core");

            var geometryFactoryPath = string.Empty;
            var preloaderLocation   = string.Empty;

            var loadedLibGVersion = PreloadAsmFromMayaATF();

            try
            {
                if (isDynModelNull)
                {
                    DynModel = DynamoModel.Start(
                        new DynamoModel.DefaultStartConfiguration
                    {
                        DynamoCorePath      = corePath,
                        DynamoHostPath      = corePath,
                        GeometryFactoryPath = GetGeometryFactoryPath(corePath, loadedLibGVersion),
                        PathResolver        = new PathResolver(userDataFolder, commonDataFolder),
                    });
                    isDynModelNull = false;
                }
                if (isDynViewModelNull)
                {
                    DynViewModel = DynamoViewModel.Start(
                        new DynamoViewModel.StartConfiguration
                    {
                        // CommandFilePath = commandFilePath,
                        DynamoModel = DynModel
                    });
                    isDynViewModelNull = false;
                }
            }
            catch (Exception e)
            {
                MGlobal.displayWarning(e.Message);
            }
        }
Exemple #15
0
        public void SetPythonTemplateFromConfigWithInvalidPath()
        {
            var templatePath = Path.Combine(@"C:\Users\SomeDynamoUser\Desktop", "PythonTemplate-initial.py");

            var config = new DynamoModel.DefaultStartConfiguration()
            {
                PythonTemplatePath = templatePath
            };

            var model = DynamoModel.Start(config);

            Assert.AreEqual(model.PreferenceSettings.PythonTemplateFilePath, string.Empty);
        }
Exemple #16
0
        public void SetPythonTemplateFromConfigWithValidPath()
        {
            var templatePath = Path.Combine(SettingDirectory, "PythonTemplate-initial.py");

            var config = new DynamoModel.DefaultStartConfiguration()
            {
                PythonTemplatePath = templatePath
            };

            var model = DynamoModel.Start(config);

            Assert.AreEqual(model.PreferenceSettings.PythonTemplateFilePath, templatePath);
        }
Exemple #17
0
        // Test checks png images. If at least one icon is not presented, test fails.
        public void SearchForPNGFiles()
        {
            var model = DynamoModel.Start();

            IEnumerable   searchEntries            = model.SearchModel.SearchEntries.OfType <NodeSearchElement>();
            IconServices  iconServices             = new IconServices(model.PathManager);
            IconWarehouse currentWarehouse         = null;
            var           currentWarehouseAssembly = string.Empty;

            List <String> missingIcons = new List <string>();

            foreach (var entry in searchEntries)
            {
                var searchEle = entry as NodeSearchElement;
                if (String.IsNullOrEmpty(searchEle.IconName))
                {
                    continue;
                }

                var smallIconName = searchEle.IconName + Configurations.SmallIconPostfix;
                var largeIconName = searchEle.IconName + Configurations.LargeIconPostfix;


                // Only retrieve the icon warehouse for different assembly.
                if (currentWarehouseAssembly != searchEle.Assembly)
                {
                    currentWarehouseAssembly = searchEle.Assembly;
                    currentWarehouse         = iconServices.GetForAssembly(searchEle.Assembly);
                }

                ImageSource smallIcon = null;
                ImageSource largeIcon = null;
                if (currentWarehouse != null)
                {
                    smallIcon = currentWarehouse.LoadIconInternal(smallIconName);
                    largeIcon = currentWarehouse.LoadIconInternal(largeIconName);
                }

                if (smallIcon == null)
                {
                    missingIcons.Add(smallIconName);
                }
                if (largeIcon == null)
                {
                    missingIcons.Add(largeIconName);
                }
            }

            Assert.IsTrue(missingIcons.Count == 0, String.Join(Environment.NewLine, missingIcons));
            model.ShutDown(false);
        }
Exemple #18
0
        protected override void StartDynamo(TestSessionConfiguration testConfig)
        {
            var preloader = new Preloader(testConfig.DynamoCorePath, testConfig.RequestedLibraryVersion);

            preloader.Preload();

            var preloadedLibraries = new List <string>();

            GetLibrariesToPreload(preloadedLibraries);

            if (preloadedLibraries.Any())
            {
                if (pathResolver == null)
                {
                    pathResolver = new TestPathResolver();
                }

                var pr = pathResolver as TestPathResolver;
                foreach (var preloadedLibrary in preloadedLibraries.Distinct())
                {
                    pr.AddPreloadLibraryPath(preloadedLibrary);
                }
            }

            Model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
            {
                StartInTestMode     = true,
                PathResolver        = pathResolver,
                GeometryFactoryPath = preloader.GeometryFactoryPath,
                UpdateManager       = this.UpdateManager,
                ProcessMode         = TaskProcessMode.Synchronous
            });

            ViewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                DynamoModel      = Model,
                Watch3DViewModel =
                    HelixWatch3DViewModel.TryCreateHelixWatch3DViewModel(
                        null,
                        new Watch3DViewModelStartupParams(Model),
                        Model.Logger)
            });

            //create the view
            View = new DynamoView(ViewModel);
            View.Show();

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
        }
Exemple #19
0
        public virtual void Start()
        {
            var assemblyPath = Assembly.GetExecutingAssembly().Location;

            preloader = new Preloader(Path.GetDirectoryName(assemblyPath));
            preloader.Preload();
            CreateTemporaryFolder();

            // Setup Temp PreferenceSetting Location for testing
            PreferenceSettings.DynamoTestPath = Path.Combine(TempFolder, "UserPreferenceTest.xml");

            TestPathResolver pathResolver = null;
            var preloadedLibraries        = new List <string>();

            GetLibrariesToPreload(preloadedLibraries);

            if (preloadedLibraries.Any())
            {
                // Only when any library needs preloading will a path resolver be
                // created, otherwise DynamoModel gets created without preloading
                // any library.
                //
                pathResolver = new TestPathResolver();
                foreach (var preloadedLibrary in preloadedLibraries.Distinct())
                {
                    pathResolver.AddPreloadLibraryPath(preloadedLibrary);
                }
            }

            Model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
            {
                StartInTestMode     = true,
                PathResolver        = pathResolver,
                GeometryFactoryPath = preloader.GeometryFactoryPath,
                ProcessMode         = Dynamo.Core.Threading.TaskProcessMode.Synchronous
            });

            ViewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                DynamoModel = Model
            });

            //create the view
            View = new DynamoView(ViewModel);
            View.Show();

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
        }
Exemple #20
0
        public void Init()
        {
            extensionsPath = Path.Combine(Directory.GetCurrentDirectory(), "extensions");
            extMock        = new Mock <IExtension>();

            model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
            {
                StartInTestMode = true,
                Extensions      = new List <IExtension> {
                    extMock.Object
                }
            });
        }
Exemple #21
0
        public void Init()
        {
            extensionsPath = Path.Combine(Directory.GetCurrentDirectory(), "extensions");
            extMock        = new Mock <IExtension>();

            model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
            {
                StartInTestMode = true,
                Extensions      = new List <IExtension> {
                    extMock.Object
                },
                ProcessMode = Core.Threading.TaskProcessMode.Synchronous
            });
        }
Exemple #22
0
        private static DynamoModel StartDynamoWithDefaultConfig(bool CLImode, string geometryFactoryPath, string preloaderLocation)
        {
            var config = new DynamoModel.DefaultStartConfiguration()
            {
                GeometryFactoryPath = geometryFactoryPath,
                ProcessMode         = TaskProcessMode.Asynchronous
            };

            config.UpdateManager   = CLImode ? null : InitializeUpdateManager();
            config.StartInTestMode = CLImode ? true : false;
            config.PathResolver    = CLImode ? new CLIPathResolver(preloaderLocation) as IPathResolver : new SandboxPathResolver(preloaderLocation) as IPathResolver;

            var model = DynamoModel.Start(config);

            return(model);
        }
Exemple #23
0
        public DynamoModel MakeModel()
        {
            var geometryFactoryPath = string.Empty;

            var config = new DynamoModel.DefaultStartConfiguration()
            {
                GeometryFactoryPath = geometryFactoryPath,
                ProcessMode         = TaskProcessMode.Asynchronous
            };

            config.PathResolver = new SandboxPathResolver() as IPathResolver;

            var model = DynamoModel.Start(config);

            return(model);
        }
        public void Init()
        {
            extMock = new Mock <IExtension>();
            extMock.Setup(ext => ext.Ready(It.IsAny <ReadyParams>())).Callback((ReadyParams r) => ExtensionReadyCallback(r));
            cmdExecutionState = -1;

            model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
            {
                StartInTestMode = true,
                Extensions      = new List <IExtension> {
                    extMock.Object
                },
                ProcessMode = TaskProcessMode.Synchronous,
            });
            //Setting this flag to true will enable to execute a specific section in the ExecuteCommand() method
            model.DebugSettings.VerboseLogging = true;
        }
Exemple #25
0
        protected virtual void StartDynamo(TestSessionConfiguration testConfig)
        {
            preloader = new Preloader(testConfig.DynamoCorePath, testConfig.RequestedLibraryVersion);
            preloader.Preload();

            var preloadedLibraries = new List <string>();

            GetLibrariesToPreload(preloadedLibraries);

            if (preloadedLibraries.Any())
            {
                if (pathResolver == null)
                {
                    pathResolver = new TestPathResolver();
                }

                var pr = pathResolver as TestPathResolver;
                foreach (var preloadedLibrary in preloadedLibraries.Distinct())
                {
                    pr.AddPreloadLibraryPath(preloadedLibrary);
                }
            }

            Model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
            {
                StartInTestMode     = true,
                PathResolver        = pathResolver,
                GeometryFactoryPath = preloader.GeometryFactoryPath,
                UpdateManager       = this.UpdateManager
            });

            ViewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                DynamoModel = Model
            });

            //create the view
            View = new DynamoView(ViewModel);
            View.Show();

            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
        }
Exemple #26
0
        protected void RunCommandsFromFile(string commandFileName,
                                           bool autoRun = false, CommandCallback commandCallback = null)
        {
            string commandFilePath = SystemTestBase.GetTestDirectory(ExecutingDirectory);

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

            if (this.ViewModel != null)
            {
                var message = "Multiple DynamoViewModel instances detected!";
                throw new InvalidOperationException(message);
            }

            var model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
            {
                StartInTestMode = true
            });

            ViewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                DynamoModel     = model,
                CommandFilePath = commandFilePath
            });

            ViewModel.HomeSpace.RunSettings.RunType = autoRun ?
                                                      RunType.Automatic :
                                                      RunType.Manual;

            RegisterCommandCallback(commandCallback);

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

            dynamoView.ShowDialog();

            Assert.IsNotNull(ViewModel);
            Assert.IsNotNull(ViewModel.Model);
            Assert.IsNotNull(ViewModel.Model.CurrentWorkspace);
            workspace          = ViewModel.Model.CurrentWorkspace;
            workspaceViewModel = ViewModel.CurrentSpaceViewModel;
        }
Exemple #27
0
        public void Init()
        {
            extensionsPath = Path.Combine(Directory.GetCurrentDirectory(), "extensions");
            extMock        = new Mock <IExtension>();
            extMock.Setup(ext => ext.Ready(It.IsAny <ReadyParams>())).Callback((ReadyParams r) => ExtensionReadyCallback(r));
            cmdExecutionState = -1;

            model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
            {
                StartInTestMode = true,
                Extensions      = new List <IExtension> {
                    extMock.Object
                },
                ProcessMode = TaskProcessMode.Synchronous
            });
            model.ExtensionManager.ExtensionAdded   += OnExtensionAdded;
            model.ExtensionManager.ExtensionRemoved += OnExtensionRemoved;
        }
Exemple #28
0
        private void RestartTestSetup(bool startInTestMode)
        {
            // Shutdown Dynamo and restart it
            View.Close();
            View = null;

            if (ViewModel != null)
            {
                var shutdownParams = new DynamoViewModel.ShutdownParams(
                    shutdownHost: false, allowCancellation: false);

                ViewModel.PerformShutdownSequence(shutdownParams);
                ViewModel = null;
            }

            // Setup Temp PreferenceSetting Location for testing
            PreferenceSettings.DynamoTestPath = Path.Combine(TempFolder, "UserPreferenceTest.xml");

            Model = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
            {
                StartInTestMode = startInTestMode,
                ProcessMode     = startInTestMode
                        ? TaskProcessMode.Synchronous
                        : TaskProcessMode.Asynchronous
            });

            ViewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                DynamoModel = Model
            });

            var expectedState = startInTestMode
                ? DynamoModel.DynamoModelState.StartedUIless
                : DynamoModel.DynamoModelState.StartedUI;

            Assert.AreEqual(ViewModel.Model.State, expectedState);

            //create the view
            View = new DynamoView(ViewModel);
            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
        }
        protected void StartDynamo()
        {
            DynamoPathManager.Instance.InitializeCore(
                Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

            DynamoPathManager.Instance.PreloadASMLibraries();

            var model = DynamoModel.Start(
                new DynamoModel.StartConfiguration()
            {
                StartInTestMode = true
            });

            this.ViewModel = DynamoViewModel.Start(
                new DynamoViewModel.StartConfiguration()
            {
                DynamoModel = model
            });
        }
Exemple #30
0
        public static DynamoModel MakeModel(bool CLImode)
        {
            var geometryFactoryPath = string.Empty;
            var preloaderLocation   = string.Empty;

            PreloadShapeManager(ref geometryFactoryPath, ref preloaderLocation);

            var config = new DynamoModel.DefaultStartConfiguration()
            {
                GeometryFactoryPath = geometryFactoryPath,
            };

            config.UpdateManager   = CLImode ? null : InitializeUpdateManager();
            config.StartInTestMode = CLImode ? true : false;
            config.PathResolver    = CLImode ? new CLIPathResolver(preloaderLocation) as IPathResolver : new SandboxPathResolver(preloaderLocation) as IPathResolver;

            var model = DynamoModel.Start(config);

            return(model);
        }