public void DefaultDIConstructor()
        {
            // Arrange
            Uri uri = new Uri("http://tempuri.org");
            EsendexCredentials credentials = new EsendexCredentials("username", "password");
            IHttpRequestHelper httpRequestHelper = new HttpRequestHelper();
            IHttpResponseHelper httpResponseHelper = new HttpResponseHelper();

            IHttpClient httpClient = new HttpClient(credentials, uri, httpRequestHelper, httpResponseHelper);

            // Act
            RestClient restClientInstance = new RestClient(httpClient);

            // Assert
            Assert.That(restClientInstance.HttpClient, Is.InstanceOf<HttpClient>());
        }
        public void DefaultDIConstructor()
        {
            // Arrange
            var credentials = new EsendexCredentials("username", "password");
            var uri = new Uri("http://tempuri.org");

            var httpRequestHelper = new HttpRequestHelper();
            var httpResponseHelper = new HttpResponseHelper();

            // Act
            var clientInstance = new HttpClient(credentials, uri, httpRequestHelper, httpResponseHelper);

            // Assert
            Assert.That(clientInstance.Credentials, Is.InstanceOf<EsendexCredentials>());
            Assert.That(clientInstance.HttpRequestHelper, Is.InstanceOf<HttpRequestHelper>());
            Assert.That(clientInstance.HttpResponseHelper, Is.InstanceOf<HttpResponseHelper>());
            Assert.That(clientInstance.Uri, Is.InstanceOf<Uri>());
        }
예제 #3
0
        public HttpResponse Submit(HttpRequest request)
        {
            try
            {
                var webRequest = HttpRequestHelper.Create(request, Uri, _version);
                HttpRequestHelper.AddCredentials(webRequest, Credentials);
                HttpRequestHelper.AddProxy(webRequest, Credentials.WebProxy);
                HttpRequestHelper.AddContent(webRequest, request);

                var webResponse = webRequest.GetResponse();

                return(HttpResponseHelper.Create(webResponse));
            }
            catch (WebException exception)
            {
                return(HttpResponseHelper.Create(exception));
            }
        }
        public void DefaultDIConstructor()
        {
            // Arrange
            Uri uri = new Uri("http://tempuri.org");
            EsendexCredentials credentials = new EsendexCredentials("username", "password");
            IHttpRequestHelper httpRequestHelper = new HttpRequestHelper();
            IHttpResponseHelper httpResponseHelper = new HttpResponseHelper();
            IHttpClient httpClient = new HttpClient(credentials, uri, httpRequestHelper, httpResponseHelper);

            IRestClient restClient = new RestClient(httpClient);
            ISerialiser serialiser = new XmlSerialiser();

            // Act
            SessionService serviceInstance = new SessionService(restClient, serialiser);

            // Assert
            Assert.That(serviceInstance.RestClient, Is.InstanceOf<RestClient>());
            Assert.That(serviceInstance.Serialiser, Is.InstanceOf<XmlSerialiser>());
        }
예제 #5
0
        public HttpResponse Submit(HttpRequest request)
        {
            try
            {
                IHttpWebRequestAdapter webRequest = HttpRequestHelper.Create(request, Uri);

                HttpRequestHelper.AddCredentials(webRequest, Credentials);

                HttpRequestHelper.AddProxy(webRequest, Credentials.WebProxy);

                HttpRequestHelper.AddContent(webRequest, request);

                IHttpWebResponseAdapter webResponse = (IHttpWebResponseAdapter)webRequest.GetResponse();

                return(HttpResponseHelper.Create(webResponse));
            }
            catch (WebException exception)
            {
                return(HttpResponseHelper.Create(exception));
            }
        }
        public void DefaultDIConstructor()
        {
            // Arrange
            var uri = new Uri("http://tempuri.org");
            var credentials = new EsendexCredentials("username", "password");
            IHttpRequestHelper httpRequestHelper = new HttpRequestHelper();
            IHttpResponseHelper httpResponseHelper = new HttpResponseHelper();
            IHttpClient httpClient = new HttpClient(credentials, uri, httpRequestHelper, httpResponseHelper);

            IRestClient restClient = new RestClient(httpClient);
            ISerialiser serialiser = new XmlSerialiser();

            // Act
            var serviceInstance = new MessagingService(restClient, serialiser, true);

            // Assert
            Assert.That(serviceInstance.RestClient, Is.InstanceOf<RestClient>());
            Assert.That(serviceInstance.Serialiser, Is.InstanceOf<XmlSerialiser>());

            Assert.IsTrue(serviceInstance.EnsureMessageIdsInResult);
        }
        public void TestInitialize()
        {
            mocks = new MockFactory(MockBehavior.Strict);

            mockHttpWebResponse = mocks.Create<IHttpWebResponseAdapter>();

            helper = new HttpResponseHelper();
        }
        public void TestInitialize()
        {
            mockHttpWebResponse = new Mock<IHttpWebResponseAdapter>();

            helper = new HttpResponseHelper();
        }