コード例 #1
0
 public void CustomConfigForEvents()
 {
     TestDiagnosticConfig(
         c => c.Http(Components.HttpConfiguration().MessageHandler(StubMessageHandler.EmptyStreamingResponse())),
         e => e.AllAttributesPrivate(true)
         .BaseUri(new Uri("http://custom"))
         .Capacity(333)
         .DiagnosticRecordingInterval(TimeSpan.FromMinutes(32))
         .FlushInterval(TimeSpan.FromMilliseconds(555))
         .InlineUsersInEvents(true)
         .UserKeysCapacity(444)
         .UserKeysFlushInterval(TimeSpan.FromMinutes(23)),
         ExpectedConfigProps.Base()
         .WithStoreDefaults()
         .WithStreamingDefaults()
         .Add("allAttributesPrivate", true)
         .Add("customEventsURI", true)
         .Add("diagnosticRecordingIntervalMillis", TimeSpan.FromMinutes(32).TotalMilliseconds)
         .Add("eventsCapacity", 333)
         .Add("eventsFlushIntervalMillis", 555)
         .Add("inlineUsersInEvents", true)
         .Add("samplingInterval", 0)     // obsolete, no way to set this
         .Add("userKeysCapacity", 444)
         .Add("userKeysFlushIntervalMillis", TimeSpan.FromMinutes(23).TotalMilliseconds)
         );
 }
        public void CustomConfigForCustomDataStore()
        {
            TestDiagnosticConfig(
                c => c.DataStore(new DataStoreFactoryWithDiagnosticDescription {
                Description = LdValue.Of("my-test-store")
            }),
                null,
                ExpectedConfigProps.Base()
                .Set("dataStoreType", "my-test-store")
                );

            TestDiagnosticConfig(
                c => c.DataStore(new DataStoreFactoryWithoutDiagnosticDescription()),
                null,
                ExpectedConfigProps.Base()
                .Set("dataStoreType", "custom")
                );

            TestDiagnosticConfig(
                c => c.DataStore(new DataStoreFactoryWithDiagnosticDescription {
                Description = LdValue.Of(4)
            }),
                null,
                ExpectedConfigProps.Base()
                .Set("dataStoreType", "custom")
                );
        }
 public void CustomConfigGeneralProperties()
 {
     TestDiagnosticConfig(
         c => c.StartWaitTime(TimeSpan.FromMilliseconds(2)),
         null,
         ExpectedConfigProps.Base()
         .Set("startWaitMillis", 2)
         );
 }
 public void CustomConfigForExternalUpdatesOnly()
 {
     TestDiagnosticConfig(
         c => c.DataSource(Components.ExternalUpdatesOnly),
         null,
         ExpectedConfigProps.Base()
         .Set("usingRelayDaemon", true)
         .Remove("reconnectTimeMillis")
         );
 }
 public void ConfigDefaults()
 {
     // Note that in all of the test configurations where the streaming or polling data source
     // is enabled, we're setting a fake HTTP message handler so it doesn't try to do any real
     // HTTP requests that would fail and (depending on timing) disrupt the test.
     TestDiagnosticConfig(
         c => c.Http(Components.HttpConfiguration().MessageHandler(StubMessageHandler.EmptyStreamingResponse())),
         null,
         ExpectedConfigProps.Base()
         );
 }
 public void CustomConfigForStreaming()
 {
     TestDiagnosticConfig(
         c => c.DataSource(
             Components.StreamingDataSource()
             .InitialReconnectDelay(TimeSpan.FromSeconds(2))
             )
         .Http(Components.HttpConfiguration().MessageHandler(StubMessageHandler.EmptyStreamingResponse())),
         null,
         ExpectedConfigProps.Base()
         .Set("reconnectTimeMillis", 2000)
         );
 }
コード例 #7
0
 public void CustomConfigForExternalUpdatesOnly()
 {
     TestDiagnosticConfig(
         c => c.DataSource(Components.ExternalUpdatesOnly),
         null,
         ExpectedConfigProps.Base()
         .WithStoreDefaults()
         .WithEventsDefaults()
         .Add("customBaseURI", false)
         .Add("customStreamURI", false)
         .Add("streamingDisabled", false)
         .Add("usingRelayDaemon", true)
         );
 }
        public void CustomConfigForHTTP()
        {
            TestDiagnosticConfig(
                c => c.Http(
                    Components.HttpConfiguration()
                    .ConnectTimeout(TimeSpan.FromMilliseconds(8888))
                    .ReadTimeout(TimeSpan.FromMilliseconds(9999))
                    .MessageHandler(StubMessageHandler.EmptyStreamingResponse())
                    ),
                null,
                ExpectedConfigProps.Base()
                .Set("connectTimeoutMillis", 8888)
                .Set("socketTimeoutMillis", 9999)
                .Set("usingProxy", false)
                .Set("usingProxyAuthenticator", false)
                );

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

            TestDiagnosticConfig(
                c => c.Http(
                    Components.HttpConfiguration()
                    .Proxy(proxy)
                    .MessageHandler(StubMessageHandler.EmptyStreamingResponse())
                    ),
                null,
                ExpectedConfigProps.Base()
                .Set("usingProxy", true)
                );

            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,
                ExpectedConfigProps.Base()
                .Set("usingProxy", true)
                .Set("usingProxyAuthenticator", true)
                );
        }
 public void CustomConfigForEvents()
 {
     TestDiagnosticConfig(
         null,
         e => e.AllAttributesPrivate(true)
         .Capacity(333)
         .DiagnosticRecordingInterval(TimeSpan.FromMinutes(32))
         .FlushInterval(TimeSpan.FromMilliseconds(555))
         .InlineUsersInEvents(true)
         .UserKeysCapacity(444)
         .UserKeysFlushInterval(TimeSpan.FromMinutes(23)),
         ExpectedConfigProps.Base()
         .Set("allAttributesPrivate", true)
         .Set("customEventsURI", false)
         .Set("diagnosticRecordingIntervalMillis", TimeSpan.FromMinutes(32).TotalMilliseconds)
         .Set("eventsCapacity", 333)
         .Set("eventsFlushIntervalMillis", 555)
         .Set("inlineUsersInEvents", true)
         .Set("userKeysCapacity", 444)
         .Set("userKeysFlushIntervalMillis", TimeSpan.FromMinutes(23).TotalMilliseconds)
         );
 }
コード例 #10
0
        public void CustomConfigForPolling()
        {
            TestDiagnosticConfig(
                c => c.DataSource(Components.PollingDataSource())
                .Http(Components.HttpConfiguration().MessageHandler(StubMessageHandler.EmptyPollingResponse())),
                null,
                ExpectedConfigProps.Base()
                .WithPollingDefaults()
                );

            TestDiagnosticConfig(
                c => c.DataSource(
                    Components.PollingDataSource()
                    .PollInterval(TimeSpan.FromSeconds(45))
                    )
                .Http(Components.HttpConfiguration().MessageHandler(StubMessageHandler.EmptyPollingResponse())),
                null,
                ExpectedConfigProps.Base()
                .WithPollingDefaults()
                .Set("pollingIntervalMillis", 45000)
                );
        }
コード例 #11
0
        public void CustomConfigForPolling()
        {
            TestDiagnosticConfig(
                c => c.DataSource(
                    Components.PollingDataSource()
                    .PollInterval(TimeSpan.FromSeconds(45))
                    )
                .Http(Components.HttpConfiguration().MessageHandler(StubMessageHandler.EmptyPollingResponse())),
                null,
                ExpectedConfigProps.Base()
                .WithStoreDefaults()
                .WithEventsDefaults()
                .Add("customBaseURI", false)
                .Add("customStreamURI", false)
                .Add("pollingIntervalMillis", 45000)
                .Add("streamingDisabled", true)
                .Add("usingRelayDaemon", false)
                );

            TestDiagnosticConfig(
                c => c.DataSource(
                    Components.PollingDataSource()
                    .BaseUri(new Uri("http://custom"))
                    .PollInterval(TimeSpan.FromSeconds(45))
                    )
                .Http(Components.HttpConfiguration().MessageHandler(StubMessageHandler.EmptyPollingResponse())),
                null,
                ExpectedConfigProps.Base()
                .WithStoreDefaults()
                .WithEventsDefaults()
                .Add("customBaseURI", true)
                .Add("customStreamURI", false)
                .Add("pollingIntervalMillis", 45000)
                .Add("streamingDisabled", true)
                .Add("usingRelayDaemon", false)
                );
        }
コード例 #12
0
        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)
                );
        }
コード例 #13
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")
                );
        }