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(StreamWithInitialData().AsMessageHandler())),
         null,
         ExpectedConfigProps.Base()
         );
 }
        public void CustomConfigForHTTP()
        {
            TestDiagnosticConfig(
                c => c.Http(
                    Components.HttpConfiguration()
                    .ConnectTimeout(TimeSpan.FromMilliseconds(8888))
                    .ResponseStartTimeout(TimeSpan.FromMilliseconds(9999))
                    .MessageHandler(StreamWithInitialData().AsMessageHandler())
                    .UseReport(true)
                    ),
                null,
                ExpectedConfigProps.Base()
                .Set("connectTimeoutMillis", 8888)
                .Set("socketTimeoutMillis", 9999)
                .Set("useReport", true)
                );

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

            TestDiagnosticConfig(
                c => c.Http(
                    Components.HttpConfiguration()
                    .Proxy(proxy)
                    .MessageHandler(StreamWithInitialData().AsMessageHandler())
                    ),
                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(StreamWithInitialData().AsMessageHandler())
                    ),
                null,
                ExpectedConfigProps.Base()
                .Set("usingProxy", true)
                .Set("usingProxyAuthenticator", true)
                );
        }
 public void CustomConfigForStreaming()
 {
     TestDiagnosticConfig(
         c => c.DataSource(
             Components.StreamingDataSource()
             .BackgroundPollInterval(TimeSpan.FromDays(1))
             .InitialReconnectDelay(TimeSpan.FromSeconds(2))
             )
         .Http(Components.HttpConfiguration().MessageHandler(StreamWithInitialData().AsMessageHandler())),
         null,
         ExpectedConfigProps.Base()
         .Set("backgroundPollingIntervalMillis", TimeSpan.FromDays(1).TotalMilliseconds)
         .Set("reconnectTimeMillis", 2000)
         );
 }
 public void CustomConfigForEvents()
 {
     TestDiagnosticConfig(
         c => c.Http(Components.HttpConfiguration().MessageHandler(StreamWithInitialData().AsMessageHandler())),
         e => e.AllAttributesPrivate(true)
         .Capacity(333)
         .DiagnosticRecordingInterval(TimeSpan.FromMinutes(32))
         .FlushInterval(TimeSpan.FromMilliseconds(555))
         .InlineUsersInEvents(true),
         ExpectedConfigProps.Base()
         .Set("allAttributesPrivate", true)
         .Set("diagnosticRecordingIntervalMillis", TimeSpan.FromMinutes(32).TotalMilliseconds)
         .Set("eventsCapacity", 333)
         .Set("eventsFlushIntervalMillis", 555)
         .Set("inlineUsersInEvents", true)
         );
 }
        public void CustomConfigForPolling()
        {
            TestDiagnosticConfig(
                c => c.DataSource(Components.PollingDataSource())
                .Http(Components.HttpConfiguration().MessageHandler(PollingResponse().AsMessageHandler())),
                null,
                ExpectedConfigProps.Base().WithPollingDefaults()
                );

            TestDiagnosticConfig(
                c => c.DataSource(
                    Components.PollingDataSource()
                    .PollInterval(TimeSpan.FromDays(1))
                    )
                .Http(Components.HttpConfiguration().MessageHandler(PollingResponse().AsMessageHandler())),
                null,
                ExpectedConfigProps.Base().WithPollingDefaults()
                .Set("pollingIntervalMillis", TimeSpan.FromDays(1).TotalMilliseconds)
                );
        }
        public void TestConfigForServiceEndpoints()
        {
            TestDiagnosticConfig(
                c => c.ServiceEndpoints(Components.ServiceEndpoints().RelayProxy("http://custom"))
                .Http(Components.HttpConfiguration().MessageHandler(StreamWithInitialData().AsMessageHandler())),
                null,
                ExpectedConfigProps.Base()
                .Set("customBaseURI", true)
                .Set("customStreamURI", 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(StreamWithInitialData().AsMessageHandler())),
                null,
                ExpectedConfigProps.Base()
                .Set("customBaseURI", true)
                .Set("customStreamURI", true)
                .Set("customEventsURI", true)
                );

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