public void GetConfiguration_ConfigurationIsValid_ReturnsConfiguration()
    {
      // Arrange
      var configuration = XDocument.Parse(@"<komfoSharp>
                                              <services>
                                                <endpoints baseUrl='https://connect.komfo.com/' >
                                                  <tokens path='/oauth20/tokens' />
                                                  <stream path='/v1/twitter/followers/stream' maxTwitterHandlesPerCall='100' maxResultsPerCall='1000'/>
                                                  <metrics path='/v1/twitter/followers/metrics' maxTwitterHandlesPerCall='100' />
                                                  <customAudiences path='/v1/ads/customaudiences' />
                                                  <customAudience path='/v1/ads/customaudiences/{audience_id}' />
                                                  <customAudienceUsers path='/v1/ads/customaudiences/{audience_id}/users' maxEntriesPerCall='5000' />
                                                  <customAudienceStatus path='/v1/ads/customaudiences/{audience_id}/status' />
                                                  <campaigns path='/v1/ads/campaigns' />
                                                  <campaignCustomAudiences path='/v1/ads/campaigns/{campaign_id}/customaudiences' />
                                                </endpoints>
                                              </services>
                                              <polling defaultTimeInterval='00:00:10' defaultAttemptsCount='6'/>
                                            </komfoSharp>");

      var xmlSource = Substitute.For<IXmlSource>();
      var configurationFactory = new AppConfigConfigurationProvider(xmlSource);
      xmlSource.GetXml().Returns(ToXmlDocument(configuration).SelectSingleNode("komfoSharp"));

      // Act
      var result = configurationFactory.GetConfiguration();

      // Assert
      result.PollingConfiguration.DefaultAttemptsCount.Should().Be(6);
      result.PollingConfiguration.DefaultTimeInterval.Should().Be(TimeSpan.FromSeconds(10));

      result.EndpointsConfiguration.Tokens.Path.Should().Be("/oauth20/tokens");

      result.EndpointsConfiguration.Metrics.Path.Should().Be("/v1/twitter/followers/metrics");
      result.EndpointsConfiguration.Metrics.MaxTwitterHandlesPerCall.Should().Be(100);

      result.EndpointsConfiguration.Stream.Path.Should().Be("/v1/twitter/followers/stream");
      result.EndpointsConfiguration.Stream.MaxTwitterHandlesPerCall.Should().Be(100);
      result.EndpointsConfiguration.Stream.MaxResultsPerCall.Should().Be(1000);

      result.EndpointsConfiguration.CustomAudiences.Path.Should().Be("/v1/ads/customaudiences");
      result.EndpointsConfiguration.CustomAudience.Path.Should().Be("/v1/ads/customaudiences/{audience_id}");
      result.EndpointsConfiguration.CustomAudienceUsers.Path.Should().Be("/v1/ads/customaudiences/{audience_id}/users");
      result.EndpointsConfiguration.CustomAudienceUsers.MaxEntriesPerCall.Should().Be(5000);
      result.EndpointsConfiguration.CustomAudienceStatus.Path.Should().Be("/v1/ads/customaudiences/{audience_id}/status");
      result.EndpointsConfiguration.Campaigns.Path.Should().Be("/v1/ads/campaigns");
      result.EndpointsConfiguration.CampaignCustomAudiences.Path.Should().Be("/v1/ads/campaigns/{campaign_id}/customaudiences");
    }
    public void GetEndpointUrl_AudienceIdIsPassedToCustomAudienceUsersEndpoint_UrlIsFormattedWithAudienceId()
    {
      // arrange
      var configuration = XDocument.Parse(@"<komfoSharp>
                                              <services>
                                                <endpoints baseUrl='https://connect.komfo.com'>
                                                  <customAudience path='/v1/ads/customaudiences/{audience_id}' />
                                                </endpoints>
                                              </services>
                                              <polling defaultTimeInterval='00:00:10' defaultAttemptsCount='6'/>
                                            </komfoSharp>");

      var xmlSource = Substitute.For<IXmlSource>();
      var configurationFactory = new AppConfigConfigurationProvider(xmlSource);
      xmlSource.GetXml().Returns(ToXmlDocument(configuration).SelectSingleNode("komfoSharp"));

      // act
      var endpointConfiguration = configurationFactory.GetConfiguration().EndpointsConfiguration;
      var url = endpointConfiguration.GetEndpointUrl(endpointConfiguration.CustomAudience, new Dictionary<string, string> { { CustomAudienceEndpoint.Parameters.AudienceId, "1" } });

      // assert
      url.ToString().Should().Be("https://connect.komfo.com/v1/ads/customaudiences/1");
    }