Exemplo n.º 1
0
        public void ShouldCreateRequestWithDefaultConfiguration()
        {
            // arrange
            var configurationFactory  = Substitute.For <IConfigurationProvider>();
            var expectedConfiguration = new MetricsRequestConfiguration
            {
                TwitterHandles = new[] { "twh1", "twh2", "twh3" },
                Fields         = MetricFields.All,
                Polling        =
                {
                    Enabled = false
                }
            };

            // act
            var metricsRequest = new MetricsRequestBuilder(configurationFactory)
                                 .TwitterHandles(expectedConfiguration.TwitterHandles)
                                 .Create();

            // assert
            metricsRequest.Should().NotBeNull();
            metricsRequest.Configuration.ShouldBeEquivalentTo(expectedConfiguration);
        }
Exemplo n.º 2
0
        public void ShouldCreateRequestWithDefaultPollingConfiguration()
        {
            // arrange
            var configurationFactory = Substitute.For <IConfigurationProvider>();
            var config = new Configuration
            {
                PollingConfiguration = new PollingConfiguration
                {
                    DefaultAttemptsCount = 4,
                    DefaultTimeInterval  = TimeSpan.FromSeconds(15)
                }
            };

            configurationFactory.GetConfiguration().Returns(config);

            var expectedConfiguration = new MetricsRequestConfiguration
            {
                TwitterHandles = new[] { "twh1", "twh2", "twh3" },
                Fields         = MetricFields.All,
                Polling        =
                {
                    Enabled  = true,
                    Interval = config.PollingConfiguration.DefaultTimeInterval,
                    Attempts = config.PollingConfiguration.DefaultAttemptsCount
                }
            };

            // act
            var metricsRequest = new MetricsRequestBuilder(configurationFactory)
                                 .TwitterHandles(expectedConfiguration.TwitterHandles)
                                 .WithPolling()
                                 .Create();

            // assert
            metricsRequest.Should().NotBeNull();
            metricsRequest.Configuration.ShouldBeEquivalentTo(expectedConfiguration);
        }