Пример #1
0
        public CyberPlatHttpClientTests()
        {
            var dummyConf = new CyberPlatHttpClientConfiguration()
            {
                CheckUrl   = @"http://google.com",
                PayUrl     = @"http://google.com",
                StatusUrl  = @"http://google.com",
                TimeoutSec = 10,
            };

            m_Client = new CyberPlatHttpClient(m_ManagerMock, dummyConf);
        }
        public CyberPlatHttpClient(ICyberPlatSignatureManager manager, CyberPlatHttpClientConfiguration configuration, HttpMessageHandler handler = null)
        {
            if (manager == null)
            {
                throw new ArgumentNullException(nameof(manager));
            }
            m_Manager = manager;

            CheckUrl  = validateUrl(configuration.CheckUrl);
            PayUrl    = validateUrl(configuration.PayUrl);
            StatusUrl = validateUrl(configuration.StatusUrl);

            m_HttpClient         = handler != null ? new HttpClient(handler) : new HttpClient();
            m_HttpClient.Timeout = TimeSpan.FromSeconds(configuration.TimeoutSec);
        }
Пример #3
0
        public void InitializingTest(CyberPlatHttpClientConfiguration conf, bool shouldSucceed)
        {
            Action action = () =>
            {
                var client = new CyberPlatHttpClient(m_ManagerMock, conf);
            };

            if (shouldSucceed)
            {
                action.ShouldNotThrow <ArgumentException>();
            }
            else
            {
                action.ShouldThrow <ArgumentException>();
            }
        }
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.AddFacility <LoggingFacility>(f => f.LogUsing <NLogFactory>().WithConfig("NLog.config"));

            container.Register(
                Component.For <HttpMessageHandler>().ImplementedBy <LoggingHttpHandler>()
                );

            container.Register(
                Component.For <ICyberPlatGate>().ImplementedBy <CyberPlatGate.CyberPlatGate>(),
                Component.For <ICyberPlatHttpClient>().ImplementedBy <CyberPlatHttpClient>(),
                Component.For <ICyberPlatSignatureManager>().ImplementedBy <CyberPlatSignatureManager>()
                );

            // Configurations
            var gateConf = new CyberPlatGateConfiguration()
            {
                AP       = AppSettings.AP,
                SD       = AppSettings.SD,
                OP       = AppSettings.OP,
                PAY_TOOL = AppSettings.PAY_TOOL,
                TERM_ID  = AppSettings.TERM_ID,
                NO_ROUTE = AppSettings.NO_ROUTE,
            };
            var clientConf = new CyberPlatHttpClientConfiguration()
            {
                CheckUrl   = AppSettings.CheckUrl,
                PayUrl     = AppSettings.PayUrl,
                StatusUrl  = AppSettings.StatusUrl,
                TimeoutSec = AppSettings.TimeoutSec,
            };
            var managerConf = new CyberPlatSignatureManagerConfiguration()
            {
                PublicKeyPath     = AppSettings.PublicKeyPath,
                SecretKeyPath     = AppSettings.SecretKeyPath,
                PublicKeySerial   = AppSettings.PublicKeySerial,
                SecretKeyPassword = AppSettings.SecretKeyPassword,
            };

            container.Register(
                Component.For <CyberPlatGateConfiguration>().Instance(gateConf),
                Component.For <CyberPlatHttpClientConfiguration>().Instance(clientConf),
                Component.For <CyberPlatSignatureManagerConfiguration>().Instance(managerConf)
                );
        }