示例#1
0
        public void TryConfigureArguments_ReturnsTrue()
        {
            var provider = new GenericWorkerProvider(new WorkerDescription(), new List <string>());
            var args     = new ArgumentsDescription();

            Assert.True(provider.TryConfigureArguments(args, null, null));
        }
示例#2
0
        private IEnumerable <IWorkerProvider> TestReadWorkerProviderFromConfig(string language, string json, string[] arguments, Mock <ILogger <object> > mockLogger)
        {
            string rootPath   = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            string workerPath = Path.Combine(rootPath, language);

            try
            {
                Directory.CreateDirectory(workerPath);

                File.WriteAllText(Path.Combine(workerPath, ScriptConstants.WorkerConfigFileName), json);

                var scriptHostConfig      = new ScriptHostConfiguration();
                var scriptSettingsManager = new ScriptSettingsManager();
                var settings = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("workers:config:path", rootPath)
                };
                scriptSettingsManager.SetConfigurationFactory(() => new ConfigurationBuilder()
                                                              .AddInMemoryCollection(settings).Build());
                return(GenericWorkerProvider.ReadWorkerProviderFromConfig(scriptHostConfig, mockLogger.Object, scriptSettingsManager));
            }
            finally
            {
                if (Directory.Exists(rootPath))
                {
                    Directory.Delete(rootPath, true);
                }
            }
        }
        public void TryConfigureArguments_ReturnsTrue()
        {
            var provider = new GenericWorkerProvider(new WorkerDescription(), string.Empty);
            var args     = new WorkerProcessArguments();

            Assert.True(provider.TryConfigureArguments(args, null, null));
        }
        public void GetDescription_ReturnsDescription()
        {
            var workerDescription = new WorkerDescription();
            var provider          = new GenericWorkerProvider(workerDescription, string.Empty);

            Assert.Equal(workerDescription, provider.GetDescription());
        }
        private IEnumerable <IWorkerProvider> TestReadWorkerProviderFromConfig(IEnumerable <TestLanguageWorkerConfig> configs, ILogger testLogger, string language = null)
        {
            try
            {
                foreach (var workerConfig in configs)
                {
                    string workerPath = Path.Combine(rootPath, workerConfig.Language);
                    Directory.CreateDirectory(workerPath);
                    File.WriteAllText(Path.Combine(workerPath, ScriptConstants.WorkerConfigFileName), workerConfig.Json);
                }

                var configBuilder = ScriptSettingsManager.CreateDefaultConfigurationBuilder()
                                    .AddInMemoryCollection(new Dictionary <string, string>
                {
                    ["workers:config:path"] = rootPath
                });
                var config = configBuilder.Build();

                var scriptHostConfig      = new ScriptHostConfiguration();
                var scriptSettingsManager = new ScriptSettingsManager(config);

                return(GenericWorkerProvider.ReadWorkerProviderFromConfig(scriptHostConfig, testLogger, scriptSettingsManager, language: language));
            }
            finally
            {
                if (Directory.Exists(rootPath))
                {
                    Directory.Delete(rootPath, true);
                }
            }
        }
示例#6
0
        public void GetDescription_ReturnsDescription()
        {
            var workerDescription = new WorkerDescription();
            var arguments         = new List <string>();
            var provider          = new GenericWorkerProvider(workerDescription, arguments);

            Assert.Equal(workerDescription, provider.GetDescription());
        }