Exemplo n.º 1
0
        public void ShouldCreateRequestWithExpectedConfiguration()
        {
            // 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.Channel | MetricFields.Engagement,
                Polling        =
                {
                    Enabled  = true,
                    Interval = TimeSpan.FromSeconds(15),
                    Attempts = 4
                }
            };

            // act
            var metricsRequest = new MetricsRequestBuilder(configurationFactory)
                                 .TwitterHandles(expectedConfiguration.TwitterHandles)
                                 .Fields(expectedConfiguration.Fields)
                                 .WithPolling(polling => polling.Interval(expectedConfiguration.Polling.Interval).Attempts(expectedConfiguration.Polling.Attempts))
                                 .Create();

            // assert
            metricsRequest.Should().NotBeNull();
            metricsRequest.Configuration.ShouldBeEquivalentTo(expectedConfiguration);
        }
Exemplo n.º 2
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);
        }