Ejemplo n.º 1
0
        public void CustomConfigForPersistentDataStore()
        {
            TestDiagnosticConfig(
                c => c.DataStore(Components.PersistentDataStore(
                                     new PersistentDataStoreFactoryWithDiagnosticDescription {
                Description = LdValue.Of("my-test-store")
            })),
                null,
                ExpectedConfigProps.Base()
                .WithStreamingDefaults()
                .WithEventsDefaults()
                .Add("dataStoreType", "my-test-store")
                );

            TestDiagnosticConfig(
                c => c.DataStore(Components.PersistentDataStore(
                                     new PersistentDataStoreAsyncFactoryWithDiagnosticDescription {
                Description = LdValue.Of("my-test-store")
            })),
                null,
                ExpectedConfigProps.Base()
                .WithStreamingDefaults()
                .WithEventsDefaults()
                .Add("dataStoreType", "my-test-store")
                );

            TestDiagnosticConfig(
                c => c.DataStore(Components.PersistentDataStore(
                                     new PersistentDataStoreFactoryWithoutDiagnosticDescription())),
                null,
                ExpectedConfigProps.Base()
                .WithStreamingDefaults()
                .WithEventsDefaults()
                .Add("dataStoreType", "custom")
                );

            TestDiagnosticConfig(
                c => c.DataStore(Components.PersistentDataStore(
                                     new PersistentDataStoreAsyncFactoryWithoutDiagnosticDescription())),
                null,
                ExpectedConfigProps.Base()
                .WithStreamingDefaults()
                .WithEventsDefaults()
                .Add("dataStoreType", "custom")
                );

            TestDiagnosticConfig(
                c => c.DataStore(Components.PersistentDataStore(
                                     new PersistentDataStoreFactoryWithDiagnosticDescription {
                Description = LdValue.Of(4)
            })),
                null,
                ExpectedConfigProps.Base()
                .WithStreamingDefaults()
                .WithEventsDefaults()
                .Add("dataStoreType", "custom")
                );

            TestDiagnosticConfig(
                c => c.DataStore(Components.PersistentDataStore(
                                     new PersistentDataStoreAsyncFactoryWithDiagnosticDescription {
                Description = LdValue.Of(4)
            })),
                null,
                ExpectedConfigProps.Base()
                .WithStreamingDefaults()
                .WithEventsDefaults()
                .Add("dataStoreType", "custom")
                );
        }
        public void TestConfigForServiceEndpoints()
        {
            TestDiagnosticConfig(
                c => c.ServiceEndpoints(Components.ServiceEndpoints().RelayProxy("http://custom"))
                .Http(Components.HttpConfiguration().MessageHandler(StubMessageHandler.EmptyStreamingResponse())),
                null,
                ExpectedConfigProps.Base()
                .Set("customBaseURI", false)     // this is the polling base URI, not relevant in streaming mode
                .Set("customStreamURI", true)
                .Set("customEventsURI", true)
                );

            TestDiagnosticConfig(
                c => c.ServiceEndpoints(Components.ServiceEndpoints().RelayProxy("http://custom"))
                .DataSource(Components.PollingDataSource())
                .Http(Components.HttpConfiguration().MessageHandler(StubMessageHandler.EmptyPollingResponse())),
                null,
                ExpectedConfigProps.Base()
                .WithPollingDefaults()
                .Set("customBaseURI", true)
                .Set("customEventsURI", true)
                );

            TestDiagnosticConfig(
                c => c.ServiceEndpoints(Components.ServiceEndpoints()
                                        .Streaming("http://custom-streaming")
                                        .Polling("http://custom-polling")
                                        .Events("http://custom-events"))
                .Http(Components.HttpConfiguration().MessageHandler(StubMessageHandler.EmptyStreamingResponse())),
                null,
                ExpectedConfigProps.Base()
                .Set("customBaseURI", false)     // this is the polling base URI, not relevant in streaming mode
                .Set("customStreamURI", true)
                .Set("customEventsURI", true)
                );

            TestDiagnosticConfig(
                c => c.DataSource(
#pragma warning disable CS0618  // using deprecated symbol
                    Components.StreamingDataSource()
                    .BaseUri(new Uri("http://custom"))
#pragma warning restore CS0618
                    )
                .Http(Components.HttpConfiguration().MessageHandler(StubMessageHandler.EmptyStreamingResponse())),
                null,
                ExpectedConfigProps.Base()
                .Set("customStreamURI", true)
                );

            TestDiagnosticConfig(
                c => c.DataSource(
#pragma warning disable CS0618  // using deprecated symbol
                    Components.PollingDataSource().BaseUri(new Uri("http://custom"))
#pragma warning restore CS0618
                    )
                .Http(Components.HttpConfiguration().MessageHandler(StubMessageHandler.EmptyPollingResponse())),
                null,
                ExpectedConfigProps.Base()
                .WithPollingDefaults()
                .Set("customBaseURI", true)
                );
        }
Ejemplo n.º 3
0
        public void CustomConfigForHTTP()
        {
            TestDiagnosticConfig(
                c => c.Http(
                    Components.HttpConfiguration()
                    .ConnectTimeout(TimeSpan.FromMilliseconds(8888))
                    .ReadTimeout(TimeSpan.FromMilliseconds(9999))
                    .MessageHandler(StubMessageHandler.EmptyStreamingResponse())
                    ),
                null,
                LdValue.BuildObject()
                .Add("connectTimeoutMillis", 8888)
                .Add("socketTimeoutMillis", 9999)
                .Add("startWaitMillis", LdClientDiagnosticEventTest.testStartWaitTime.TotalMilliseconds)
                .Add("usingProxy", false)
                .Add("usingProxyAuthenticator", false)
                .WithStoreDefaults()
                .WithStreamingDefaults()
                .WithEventsDefaults()
                );

            var proxyUri = new Uri("http://fake");
            var proxy    = new WebProxy(proxyUri);

            TestDiagnosticConfig(
                c => c.Http(
                    Components.HttpConfiguration()
                    .Proxy(proxy)
                    .MessageHandler(StubMessageHandler.EmptyStreamingResponse())
                    ),
                null,
                LdValue.BuildObject()
                .Add("connectTimeoutMillis", HttpConfigurationBuilder.DefaultConnectTimeout.TotalMilliseconds)
                .Add("socketTimeoutMillis", HttpConfigurationBuilder.DefaultReadTimeout.TotalMilliseconds)
                .Add("startWaitMillis", LdClientDiagnosticEventTest.testStartWaitTime.TotalMilliseconds)
                .Add("usingProxy", true)
                .Add("usingProxyAuthenticator", false)
                .WithStoreDefaults()
                .WithStreamingDefaults()
                .WithEventsDefaults()
                );

            var credentials = new CredentialCache();

            credentials.Add(proxyUri, "Basic", new NetworkCredential("user", "pass"));
            var proxyWithAuth = new WebProxy(proxyUri);

            proxyWithAuth.Credentials = credentials;
            TestDiagnosticConfig(
                c => c.Http(
                    Components.HttpConfiguration()
                    .Proxy(proxyWithAuth)
                    .MessageHandler(StubMessageHandler.EmptyStreamingResponse())
                    ),
                null,
                LdValue.BuildObject()
                .Add("connectTimeoutMillis", HttpConfigurationBuilder.DefaultConnectTimeout.TotalMilliseconds)
                .Add("socketTimeoutMillis", HttpConfigurationBuilder.DefaultReadTimeout.TotalMilliseconds)
                .Add("startWaitMillis", LdClientDiagnosticEventTest.testStartWaitTime.TotalMilliseconds)
                .Add("usingProxy", true)
                .Add("usingProxyAuthenticator", true)
                .WithStoreDefaults()
                .WithStreamingDefaults()
                .WithEventsDefaults()
                );
        }