コード例 #1
0
        protected virtual void StartDynamo(IPreferences settings = null)
        {
            var assemblyPath = Assembly.GetExecutingAssembly().Location;

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

            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);
                }
            }

            this.CurrentDynamoModel = DynamoModel.Start(CreateStartConfiguration(settings));
        }
コード例 #2
0
ファイル: LibraryTests.cs プロジェクト: tshcha/Dynamo
        public override void Setup()
        {
            base.Setup();

            libraryCore = new ProtoCore.Core(new Options());
            libraryCore.Compilers.Add(Language.Associative, new ProtoAssociative.Compiler(libraryCore));
            libraryCore.Compilers.Add(Language.Imperative, new ProtoImperative.Compiler(libraryCore));
            libraryCore.ParsingMode = ParseMode.AllowNonAssignment;

            var pathResolver = new TestPathResolver();

            pathResolver.AddPreloadLibraryPath("Builtin.dll");
            pathResolver.AddPreloadLibraryPath("DSCoreNodes.dll");

            var pathManager = new PathManager(new PathManagerParams
            {
                PathResolver = pathResolver
            });

            var settings = new PreferenceSettings();

            libraryServices = new LibraryServices(libraryCore, pathManager, settings);

            RegisterEvents();
        }
コード例 #3
0
        public void Setup()
        {
            testConsole       = new TestConsole();
            testConfigHandler = new Mock <IConfigHandler>();
            testConfigHandler.Setup(m => m.DoesConfigExist(It.IsAny <string>())).Returns(true);

            testFileSystem = new MockFileSystem(new Dictionary <string, MockFileData> {
                { @"c:\config.linker", new MockFileData("<?xml version=\"1.0\" encoding=\"utf-16\"?><Config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" Version=\"v1.1.1\"></Config>") },
                { @"c:\invalidconfig.linker", new MockFileData("This content is invalid for a linker file!") },
                { @"c:\demo\jQuery.js", new MockFileData("some js") },
                { @"c:\demo\image.gif", new MockFileData(new byte[] { 0x12, 0x34, 0x56, 0xd2 }) },
                { @"somedirectory", new MockDirectoryData() }
            });

            testLinks  = new List <ConfigLink>();
            testConfig = new Mock <IConfig>();
            testConfig.Setup(m => m.LinkList).Returns(testLinks);

            testLinkElements = new ConfigLink[] {
                new ConfigLink(@"c:\config_that_does_not_exist.linker", "target", ConfigLink.LinkType.Symbolic),
                new ConfigLink(@"c:\config.linker", "target", ConfigLink.LinkType.Symbolic),
                new ConfigLink(@"somedirectory", "target", ConfigLink.LinkType.Hard),
                new ConfigLink(@"somedirectory", "anothertarget", ConfigLink.LinkType.Default),
            };

            testPathFormatter = new TestPathResolver();
        }
コード例 #4
0
        public void Setup()
        {
            testFileSystem = new MockFileSystem(new Dictionary <string, MockFileData> {
                { @"c:/testfile1.txt", new MockFileData("random data") },
                { @"c:/testfile2.txt", new MockFileData("random data") },
                { @"c:/testfile3.txt", new MockFileData("random data") },

                { @"c:/subdir1/testfile4.txt", new MockFileData("random data") },
                { @"c:/subdir1/testfile5.txt", new MockFileData("random data") },
                { @"c:/subdir1/testfile6.txt", new MockFileData("random data") },

                { @"c:/subdir2/testfile7.txt", new MockFileData("random data") },
                { @"c:/subdir2/testfile8.txt", new MockFileData("random data") },

                { @"c:/subdir2/subdir/subdir/testfile8.txt", new MockFileData("random data") },
            });

            testLinks = new List <ConfigLink> ();

            testConsole       = new TestConsole();
            testConfigHandler = new Mock <IConfigHandler> ();
            testConfigHandler.Setup(m => m.DoesConfigExist(It.IsAny <string> ())).Returns(true);

            testConfig = new Mock <IConfig> ();
            testConfig.Setup(m => m.LinkList).Returns(testLinks);
            testPathFormatter = new TestPathResolver();

            testConfigHandler.Setup(m => m.LoadConfig(It.IsAny <string> ())).Returns(testConfig.Object);
        }
コード例 #5
0
        public void Setup()
        {
            testFileSystem = new MockFileSystem(new Dictionary <string, MockFileData> {
                { @"c:\config.linker", new MockFileData("<?xml version=\"1.0\" encoding=\"utf-16\"?><Config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" Version=\"v1.1.1\"></Config>") },
                { @"c:\invalidconfig.linker", new MockFileData("This content is invalid for a linker file!") },
                { @"c:\demo\jQuery.js", new MockFileData("some js") },
                { @"c:\demo\image.gif", new MockFileData(new byte[] { 0x12, 0x34, 0x56, 0xd2 }) }
            });

            testConsole       = new TestConsole();
            testConfigHandler = new Mock <IConfigHandler>();

            testLinks = new List <ConfigLink>();

            testLinkElements = new ConfigLink[] {
                new ConfigLink("source", "target", ConfigLink.LinkType.Default),
                new ConfigLink("testing is fun", "not really", ConfigLink.LinkType.Hard)
            };

            testVariables = new List <Variable>();

            testConfig = new Mock <IConfig>();
            testConfig.Setup(m => m.LinkList).Returns(testLinks);
            testConfig.Setup(m => m.Variables).Returns(testVariables);

            testPathResolver = new TestPathResolver();
        }
コード例 #6
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());
        }
コード例 #7
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;
        }
コード例 #8
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());
        }
コード例 #9
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());
        }
コード例 #10
0
        public void Setup()
        {
            testConsole = new TestConsole();

            testConfigHandler = new Mock <IConfigHandler>();
            testConfigHandler.Setup(m => m.DoesConfigExist(It.IsAny <string>())).Returns(true);

            testFileSystem = new MockFileSystem();

            testLinks     = new List <ConfigLink>();
            testVariables = new List <Variable>();

            testConfig = new Mock <IConfig>();
            testConfig.Setup(m => m.LinkList).Returns(testLinks);
            testConfig.Setup(m => m.Variables).Returns(testVariables);

            testPathResolver = new TestPathResolver();
        }
コード例 #11
0
        public void Setup()
        {
            testConsole = new TestConsole();

            testFileSystem = new MockFileSystem(new Dictionary <string, MockFileData> {
                { @"c:/config.linker", new MockFileData("<?xml version=\"1.0\" encoding=\"utf-16\"?><Config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" Version=\"v1.1.1\"></Config>") },
                { @"c:/invalidconfig.linker", new MockFileData("This content is invalid for a linker file!") },
                { @"c:/demo/jQuery.js", new MockFileData("some js") },
                { @"c:/demo/image.gif", new MockFileData(new byte[] { 0x12, 0x34, 0x56, 0xd2 }) },
                { @"c:/somedirectory/", new MockDirectoryData() },

                // Simulate circular junction / symbolic directory
                // The loop folder in this case is a symlink to c:\
                // causing this kind of pattern when enumerating directories
                { @"c:/somedirectory/loop/somedirectory/loop/somedirectory/loop/", new MockDirectoryData() }
            });

            testPathResolver = new TestPathResolver();
        }
コード例 #12
0
        public void Setup()
        {
            testConsole       = new TestConsole();
            testConfigHandler = new Mock <IConfigHandler>();
            testConfigHandler.Setup(m => m.DoesConfigExist(It.IsAny <string>())).Returns(true);
            testLinker = new Mock <ILinker>();

            testFileSystem = new MockFileSystem(new Dictionary <string, MockFileData> {
                { @"c:\config.linker", new MockFileData("<?xml version=\"1.0\" encoding=\"utf-16\"?><Config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" Version=\"v1.1.1\"></Config>") },
                { @"c:\invalidconfig.linker", new MockFileData("This content is invalid for a linker file!") },
                { @"c:\demo\jQuery.js", new MockFileData("some js") },
                { @"c:\demo\image.gif", new MockFileData(new byte[] { 0x12, 0x34, 0x56, 0xd2 }) }
            });

            testLinks  = new List <ConfigLink>();
            testConfig = new Mock <IConfig>();
            testConfig.Setup(m => m.LinkList).Returns(testLinks);

            testPathResolver = new TestPathResolver();
        }
コード例 #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.
                //
                pathResolver = new TestPathResolver();
                foreach (var preloadedLibrary in preloadedLibraries.Distinct())
                {
                    pathResolver.AddPreloadLibraryPath(preloadedLibrary);
                }
            }

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

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

            this.ViewModel.RequestUserSaveWorkflow += RequestUserSaveWorkflow;
        }
コード例 #14
0
ファイル: SchedulerTests.cs プロジェクト: rafatahmed/Dynamo
        protected void StartDynamo()
        {
            var assemblyPath = Assembly.GetExecutingAssembly().Location;

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

            var pathResolver = new TestPathResolver();

            pathResolver.AddPreloadLibraryPath("DSCoreNodes.dll");

            schedulerThread = new SampleSchedulerThread();
            dynamoModel     = DynamoModel.Start(
                new DynamoModel.DefaultStartConfiguration()
            {
                // See documentation for 'SchedulerIntegrationTests' above.
                StartInTestMode     = false,
                SchedulerThread     = schedulerThread,
                PathResolver        = pathResolver,
                GeometryFactoryPath = preloader.GeometryFactoryPath
            });
        }
コード例 #15
0
        public override void Setup()
        {
            base.Setup();

            libraryCore = new ProtoCore.Core(new Options {
                RootCustomPropertyFilterPathName = string.Empty
            });
            libraryCore.Compilers.Add(Language.kAssociative, new ProtoAssociative.Compiler(libraryCore));
            libraryCore.Compilers.Add(Language.kImperative, new ProtoImperative.Compiler(libraryCore));
            libraryCore.ParsingMode = ParseMode.AllowNonAssignment;

            var pathResolver = new TestPathResolver();

            pathResolver.AddPreloadLibraryPath("DSCoreNodes.dll");

            var pathManager = new PathManager(new PathManagerParams
            {
                PathResolver = pathResolver
            });

            libraryServices = new LibraryServices(libraryCore, pathManager);

            RegisterEvents();
        }
コード例 #16
0
 private static string ResolveTestPath(string fileName)
 {
     return(TestPathResolver.Resolve(Path.Combine("TestFiles", "IconConverter", fileName)));
 }