コード例 #1
0
        public DaprTestBase(ITestOutputHelper output,
                            IDictionary <string, string> environmentVariables)
        {
            this.logProvider  = new TestLogProvider(output);
            this.typeLocator  = new TestFunctionTypeLocator();
            this.nameResolver = new TestNameResolver();

            foreach (var kvPair in DefaultEnvironmentVariables)
            {
                if (!environmentVariables.ContainsKey(kvPair.Key))
                {
                    environmentVariables[kvPair.Key] = kvPair.Value;
                }
            }

            foreach (var kvPair in environmentVariables)
            {
                this.nameResolver.AddSetting(kvPair.Key, kvPair.Value);
            }

            this.functionsHost = new HostBuilder()
                                 .ConfigureLogging(loggingBuilder => loggingBuilder.AddProvider(this.logProvider))
                                 .ConfigureWebJobs(webJobsBuilder => webJobsBuilder.AddDapr())
                                 .ConfigureServices(
                collection =>
            {
                collection.AddSingleton <INameResolver>(this.nameResolver);
                collection.AddSingleton <ITypeLocator>(this.typeLocator);
            })
                                 .Build();
            this.daprRuntime = new DaprRuntimeEmulator(DaprPort);
        }
コード例 #2
0
        public DaprTestBase(ITestOutputHelper output)
        {
            this.logProvider  = new TestLogProvider(output);
            this.typeLocator  = new TestFunctionTypeLocator();
            this.nameResolver = new TestNameResolver();

            // Use 3501 to avoid conflicting with the real Dapr port number
            int daprPort = 3501;

            this.nameResolver.AddSetting("DAPR_HTTP_PORT", daprPort.ToString());

            this.functionsHost = new HostBuilder()
                                 .ConfigureLogging(loggingBuilder => loggingBuilder.AddProvider(this.logProvider))
                                 .ConfigureWebJobs(webJobsBuilder => webJobsBuilder.AddDapr())
                                 .ConfigureServices(
                collection =>
            {
                collection.AddSingleton <INameResolver>(this.nameResolver);
                collection.AddSingleton <ITypeLocator>(this.typeLocator);
            })
                                 .Build();
            this.daprRuntime = new DaprRuntimeEmulator(daprPort);
        }