示例#1
0
        public void ShouldCreateSpecifiedPollingConfiguration()
        {
            // arrange
            var configurationProvider = Substitute.For <IConfigurationProvider>();

            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 withPollingBuilder = new WithPollingBuilder(configurationProvider);

            var pollingConfiguration = withPollingBuilder
                                       .Interval(expectedPollingRequestConfiguration.Interval)
                                       .Attempts(expectedPollingRequestConfiguration.Attempts)
                                       .Create();

            // assert
            pollingConfiguration.ShouldBeEquivalentTo(expectedPollingRequestConfiguration);
        }
示例#2
0
        public void ShouldCreateRequestWithPassedCampaignConfigurationAndSpecifiedPollingConfiguration()
        {
            // arrange
            var configurationProvider = Substitute.For <IConfigurationProvider>();

            var configuration = new Configuration
            {
                PollingConfiguration = new PollingConfiguration
                {
                    DefaultAttemptsCount = 4,
                    DefaultTimeInterval  = TimeSpan.FromSeconds(15.0)
                }
            };

            var newCampaignConfiguration = new Campaign
            {
                ExtCampaignId  = Guid.NewGuid().ToString(),
                ExtCampaignKey = Guid.NewGuid().ToString(),
                Description    = Guid.NewGuid().ToString(),
                Name           = Guid.NewGuid().ToString()
            };

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

            configurationProvider.GetConfiguration().Returns(configuration);

            // act
            var newCampaignRequestBuilder = new NewCampaignRequestBuilder(configurationProvider, newCampaignConfiguration);

            var newCampaignRequest = newCampaignRequestBuilder
                                     .WithPolling(polling => polling
                                                  .Interval(expectedPollingRequestConfiguration.Interval)
                                                  .Attempts(expectedPollingRequestConfiguration.Attempts))
                                     .Create();

            // assert
            newCampaignRequest.Should().NotBeNull();
            newCampaignRequest.Configuration.Should().NotBeNull();
            newCampaignRequest.Configuration.Campaign.ShouldBeEquivalentTo(newCampaignConfiguration);
            newCampaignRequest.Configuration.Polling.Should().NotBeNull();
            newCampaignRequest.Configuration.Polling.ShouldBeEquivalentTo(expectedPollingRequestConfiguration);
        }
示例#3
0
        public void ShouldCreateRequestWithPassedDataAndSpecifiedPollingConfiguration()
        {
            // arrange
            var configurationProvider = Substitute.For <IConfigurationProvider>();
            var campaignId            = Guid.NewGuid().ToString();
            var updateCustomAudiencesConfiguration = new UpdateCustomAudiencesInCampaignConfiguration
            {
                CustomAudienceId = Guid.NewGuid().ToString()
            };

            var configuration = new Configuration
            {
                PollingConfiguration = new PollingConfiguration
                {
                    DefaultTimeInterval  = TimeSpan.FromSeconds(15.0),
                    DefaultAttemptsCount = 4
                }
            };

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

            configurationProvider.GetConfiguration().Returns(configuration);

            // act
            var removeCustomAudienceRequestBuilder = new RemoveCustomAudienceFromCampaignRequestBuilder(configurationProvider, campaignId, updateCustomAudiencesConfiguration);

            var removeCustomAudienceRequest = removeCustomAudienceRequestBuilder
                                              .WithPolling(polling => polling
                                                           .Interval(expectedPollingRequestConfiguration.Interval)
                                                           .Attempts(expectedPollingRequestConfiguration.Attempts))
                                              .Create();

            // assert
            removeCustomAudienceRequest.Should().NotBeNull();
            removeCustomAudienceRequest.Configuration.Should().NotBeNull();
            removeCustomAudienceRequest.Configuration.CampaignId.Should().Be(campaignId);
            removeCustomAudienceRequest.Configuration.CustomAudiences.Should().NotBeNull();
            removeCustomAudienceRequest.Configuration.CustomAudiences.ShouldBeEquivalentTo(updateCustomAudiencesConfiguration);
            removeCustomAudienceRequest.Configuration.Polling.Should().NotBeNull();
            removeCustomAudienceRequest.Configuration.Polling.ShouldBeEquivalentTo(expectedPollingRequestConfiguration);
        }
示例#4
0
        public void ShouldCreateRequestWithPassedDataAndSpecifiedPollingConfiguration()
        {
            // arrange
            var configurationProvider    = Substitute.For <IConfigurationProvider>();
            var customAudienceId         = Guid.NewGuid().ToString();
            var updateUsersConfiguration = new UpdateUsersInCustomAudienceConfiguration
            {
                Data = new[] { Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString() },
                FacebookApplicationsIds = new[] { Guid.NewGuid().ToString(), 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 removeUsersRequestBuilder = new RemoveUsersFromCustomAudienceRequestBuilder(configurationProvider, customAudienceId, updateUsersConfiguration);

            var removeUsersRequest = removeUsersRequestBuilder
                                     .WithPolling(polling => polling
                                                  .Interval(expectedPollingRequestConfiguration.Interval)
                                                  .Attempts(expectedPollingRequestConfiguration.Attempts))
                                     .Create();

            // assert
            removeUsersRequest.Should().NotBeNull();
            removeUsersRequest.Configuration.Should().NotBeNull();
            removeUsersRequest.Configuration.Users.Should().NotBeNull();
            removeUsersRequest.Configuration.Users.ShouldBeEquivalentTo(updateUsersConfiguration);
            removeUsersRequest.Configuration.Polling.Should().NotBeNull();
            removeUsersRequest.Configuration.Polling.ShouldBeEquivalentTo(expectedPollingRequestConfiguration);
        }
        public void ShouldCreateCampaignsRequestWithSpecifiedPollingConfiguration()
        {
            // arrange
            var configurationProvider = Substitute.For <IConfigurationProvider>();

            var configuration = new Configuration
            {
                PollingConfiguration = new PollingConfiguration
                {
                    DefaultTimeInterval  = TimeSpan.FromSeconds(15.0),
                    DefaultAttemptsCount = 4
                }
            };

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

            configurationProvider.GetConfiguration().Returns(configuration);

            // act
            var campaignsRequestBuilder = new CampaignsRequestBuilder(configurationProvider);

            var campaignsRequest = campaignsRequestBuilder
                                   .WithPolling(polling => polling
                                                .Interval(expectedPollingRequestConfiguration.Interval)
                                                .Attempts(expectedPollingRequestConfiguration.Attempts))
                                   .Create();

            // assert
            campaignsRequest.Should().NotBeNull();
            campaignsRequest.Configuration.Should().NotBeNull();
            campaignsRequest.Configuration.Polling.ShouldBeEquivalentTo(expectedPollingRequestConfiguration);
        }