Exemple #1
0
        public void TestGetServerMetaDataHeadersWithAdditionalHeaders()
        {
            IList <RequestHeader> additionalHeaders = new List <RequestHeader>();

            additionalHeaders.Add(new RequestHeader("Header1", "Value1"));
            additionalHeaders.Add(new RequestHeader("Header2", "Value2"));
            additionalHeaders.Add(new RequestHeader("Header3", "Value3"));

            MetaDataProvider metaDataProvider = new MetaDataProviderBuilder("OnlinePayments")
            {
                AdditionalRequestHeaders = additionalHeaders
            }.Build();

            IEnumerable <RequestHeader> requestHeaders = metaDataProvider.ServerMetaDataHeaders;

            Assert.AreEqual(4, requestHeaders.Count());
            RequestHeader requestHeader = requestHeaders.First();

            AssertServerMetaInfo(metaDataProvider, requestHeader);

            IEnumerator <RequestHeader> enumerator = requestHeaders.GetEnumerator();

            enumerator.MoveNext();
            foreach (RequestHeader additionalHeader in additionalHeaders)
            {
                Assert.True(enumerator.MoveNext());
                requestHeader = enumerator.Current;
                Assert.AreEqual(requestHeader, additionalHeader);
            }
        }
Exemple #2
0
        /// <summary>
        /// Creates a <see cref="CommunicatorBuilder"/> based on the passed configuration.
        /// </summary>
        /// <returns>The communicator builder that can still be changed.</returns>
        public static CommunicatorBuilder CreateCommunicatorBuilder(CommunicatorConfiguration configuration)
        {
            MetaDataProvider metaDataProvider = new MetaDataProviderBuilder(configuration.Integrator)
                                                .WithShoppingCartExtension(configuration.ShoppingCartExtension)
                                                .Build();

            return(new CommunicatorBuilder()
                   .WithApiEndpoint(configuration.ApiEndpoint)
                   .WithConnection(new DefaultConnection(
                                       configuration.ProxyConfiguration,
                                       configuration.SocketTimeout,
                                       // connection timeout not supported
                                       configuration.MaxConnections))
                   .WithAuthenticator(new DefaultAuthenticator(
                                          configuration.AuthorizationType,
                                          configuration.ApiKeyId,
                                          configuration.SecretApiKey
                                          ))
                   .WithMarshaller(DefaultMarshaller.Instance)
                   .WithMetaDataProvider(metaDataProvider));
        }
Exemple #3
0
        public static void CheckWithAdditionalRequestHeader(string additionalHeaderName, bool isAllowed)
        {
            RequestHeader additionalRequestHeader = new RequestHeader(additionalHeaderName, Guid.NewGuid().ToString());

            MetaDataProviderBuilder builder = new MetaDataProviderBuilder("OnlinePayments");

            if (isAllowed)
            {
                MetaDataProvider            metaDataProvider = builder.WithAdditionalRequestHeader(additionalRequestHeader).Build();
                IEnumerable <RequestHeader> requestHeaders   = metaDataProvider.ServerMetaDataHeaders;
                Assert.AreEqual(2, requestHeaders.Count());

                RequestHeader requestHeader = requestHeaders.First();
                Assert.AreEqual("X-GCS-ServerMetaInfo", requestHeader.Name);

                requestHeader = requestHeaders.Skip(1).First();
                Assert.AreEqual(requestHeader, additionalRequestHeader);
            }
            else
            {
                Assert.That((() => builder.WithAdditionalRequestHeader(additionalRequestHeader)), Throws.ArgumentException.With.Message.Contains(additionalHeaderName));
            }
        }
Exemple #4
0
 public MetaDataProvider(MetaDataProviderBuilder builder)
     : this(builder.Integrator, builder.ShoppingCartExtension, builder.AdditionalRequestHeaders)
 {
 }