示例#1
0
        public void ShouldCreateRequestWithDefaultPollingConfiguration()
        {
            // arrange
            var configurationProvider = Substitute.For <IConfigurationProvider>();
            var customAudienceId      = Guid.NewGuid().ToString();
            var configuration         = new Configuration
            {
                PollingConfiguration = new PollingConfiguration
                {
                    DefaultAttemptsCount = 4,
                    DefaultTimeInterval  = TimeSpan.FromSeconds(15.0)
                }
            };

            configurationProvider.GetConfiguration().Returns(configuration);

            // act
            var customAudienceRequestBuilder = new CustomAudienceRequestBuilder(configurationProvider, customAudienceId);

            var customAudienceRequest = customAudienceRequestBuilder.WithPolling().Create();

            // assert
            customAudienceRequest.Should().NotBeNull();
            customAudienceRequest.Configuration.Should().NotBeNull();
            customAudienceRequest.Configuration.CustomAudienceId.Should().Be(customAudienceId);
            customAudienceRequest.Configuration.Polling.Should().NotBeNull();
            customAudienceRequest.Configuration.Polling.Enabled.Should().BeTrue();
            customAudienceRequest.Configuration.Polling.Attempts.Should().Be(configuration.PollingConfiguration.DefaultAttemptsCount);
            customAudienceRequest.Configuration.Polling.Interval.Should().Be(configuration.PollingConfiguration.DefaultTimeInterval);
        }
示例#2
0
        public void ShouldCreateRequestWithSpecifiedPollingConfiguration()
        {
            // arrange
            var configurationProvider = Substitute.For <IConfigurationProvider>();
            var customAudienceId      = Guid.NewGuid().ToString();
            var configuration         = new Configuration
            {
                PollingConfiguration = new PollingConfiguration
                {
                    DefaultAttemptsCount = 4,
                    DefaultTimeInterval  = TimeSpan.FromSeconds(15.0)
                }
            };

            var expectedPollingRequestConfiguration = new PollingRequestConfiguration
            {
                Enabled  = true,
                Attempts = 6,
                Interval = TimeSpan.FromSeconds(10.0)
            };

            configurationProvider.GetConfiguration().Returns(configuration);

            // act
            var customAudienceRequestBuilder = new CustomAudienceRequestBuilder(configurationProvider, customAudienceId);

            var customAudienceRequest = customAudienceRequestBuilder
                                        .WithPolling(polling => polling
                                                     .Interval(expectedPollingRequestConfiguration.Interval)
                                                     .Attempts(expectedPollingRequestConfiguration.Attempts))
                                        .Create();

            // assert
            customAudienceRequest.Should().NotBeNull();
            customAudienceRequest.Configuration.Should().NotBeNull();
            customAudienceRequest.Configuration.CustomAudienceId.Should().Be(customAudienceId);
            customAudienceRequest.Configuration.Polling.Should().NotBeNull();
            customAudienceRequest.Configuration.Polling.ShouldBeEquivalentTo(expectedPollingRequestConfiguration);
        }