Esempio n. 1
0
        public void Webservice_Test_WhenRequestShouldNotTimeout_ExpectNoMessage()
        {
            //------------Setup for test--------------------------
            var serviceXml = XmlResource.Fetch("WebService");
            var sourceXml  = XmlResource.Fetch("WebSource");
            var response   = JsonResource.Fetch("empty");

            var service = new WebService(serviceXml)
            {
                Source = new WebSource(sourceXml)
            };

            foreach (var parameter in service.Method.Parameters)
            {
                parameter.Value = parameter.DefaultValue;
            }

            var webExecuteHitCount = 0;
            var resourceCatalog    = new Mock <IResourceCatalog>();
            var services           = new WebServicesMock(resourceCatalog.Object,
                                                         (WebSource source, WebRequestMethod method, string uri, string data, bool error, out ErrorResultTO errors, string[] headers) =>
            {
                webExecuteHitCount++;
                errors = new ErrorResultTO();
                return(response);
            });

            //------------Execute Test---------------------------
            var result = services.Test(service.ToString(), Guid.Empty, Guid.Empty);

            //------------Assert Results-------------------------
            Assert.AreEqual(1, webExecuteHitCount);
            Assert.AreEqual(string.Empty, result.RequestMessage);
        }
Esempio n. 2
0
        public void WebServices_Test_With_InValidArgs_ExpectedReturnsResponseWithErrorMessage()
        {
            var serviceXml = XmlResource.Fetch("WebService");

            var service = new WebService(serviceXml)
            {
                Source = new WebSource
                {
                    Address = "someAddress",
                }
            };

            foreach (var parameter in service.Method.Parameters)
            {
                parameter.Value = parameter.DefaultValue;
            }

            var services = new WebServicesMock();
            var result   = services.Test(service.ToString(), Guid.Empty, Guid.Empty);

            Assert.AreEqual("Illegal characters in path.", result.RequestResponse);
            Assert.AreEqual(1, result.Recordsets.Count);
            Assert.IsTrue(result.Recordsets[0].HasErrors);
            Assert.AreEqual("Illegal characters in path.", result.Recordsets[0].ErrorMessage);
        }
Esempio n. 3
0
        public void WebServicesTestWithValidArgsAndNonEmptyResponseExpectedFetchesRecordsetOnly()
        {
            var serviceXml  = XmlResource.Fetch("WebService");
            var sourceXml   = XmlResource.Fetch("WebSource");
            var responseXml = XmlResource.Fetch("WebServiceResponse");

            var service = new WebService(serviceXml)
            {
                Source = new WebSource(sourceXml), RequestResponse = responseXml.ToString()
            };

            foreach (var parameter in service.Method.Parameters)
            {
                parameter.Value = parameter.DefaultValue;
            }

            var webExecuteHitCount = 0;
            var resourceCatalog    = new Mock <IResourceCatalog>();
            var services           = new WebServicesMock(resourceCatalog.Object,
                                                         (WebSource source, WebRequestMethod method, string uri, string data, bool error, out ErrorResultTO errors, string[] headers) =>
            {
                webExecuteHitCount++;
                errors = new ErrorResultTO();
                return(string.Empty);
            });

            var result = services.Test(service.ToString(), Guid.Empty, Guid.Empty);

            Assert.AreEqual(0, webExecuteHitCount);

            // BUG 9626 - 2013.06.11 - TWR: RecordsetListHelper.ToRecordsetList returns correct number of recordsets now
            Assert.AreEqual(1, result.Recordsets.Count);
            Assert.AreEqual("", result.Recordsets[0].Name);
        }
        public void Webservice_Test_WhenRequestShouldTimeout_ExpectTimeoutMessage()
        {
            //------------Setup for test--------------------------
            var serviceXml = XmlResource.Fetch("WebService");
            var sourceXml = XmlResource.Fetch("WebSource");
            var response = JsonResource.Fetch("cryptsy_all_markets");

            var service = new WebService(serviceXml) { Source = new WebSource(sourceXml) };

            foreach(var parameter in service.Method.Parameters)
            {
                parameter.Value = parameter.DefaultValue;
            }

            var webExecuteHitCount = 0;
            var resourceCatalog = new Mock<IResourceCatalog>();
            var services = new WebServicesMock(resourceCatalog.Object,
                (WebSource source, WebRequestMethod method, string uri, string data, bool error, out ErrorResultTO errors, string[] headers) =>
                {
                    webExecuteHitCount++;
                    errors = new ErrorResultTO();
                    return response;
                });

            //------------Execute Test---------------------------
            var result = services.Test(service.ToString(), Guid.Empty, Guid.Empty);

            //------------Assert Results-------------------------
            Assert.AreEqual(1, webExecuteHitCount);
            Assert.AreEqual(GlobalConstants.WebServiceTimeoutMessage, result.RequestMessage);
        }
        public void WebServicesTestWithInValidArgsExpectedReturnsResponseWithErrorMessage()
        {
            var serviceXml = XmlResource.Fetch("WebService");

            var service = new WebService(serviceXml);

            foreach(var parameter in service.Method.Parameters)
            {
                parameter.Value = parameter.DefaultValue;
            }

            var services = new WebServicesMock();
            var result = services.Test(service.ToString(), Guid.Empty, Guid.Empty);

            Assert.AreEqual("Illegal characters in path.", result.RequestResponse);
            Assert.AreEqual(1, result.Recordsets.Count);
            Assert.IsTrue(result.Recordsets[0].HasErrors);
            Assert.AreEqual("Illegal characters in path.", result.Recordsets[0].ErrorMessage);
        }
        public void WebServicesTestWithValidArgsAndNonEmptyResponseExpectedFetchesRecordsetOnly()
        {
            var serviceXml = XmlResource.Fetch("WebService");
            var sourceXml = XmlResource.Fetch("WebSource");
            var responseXml = XmlResource.Fetch("WebServiceResponse");

            var service = new WebService(serviceXml) { Source = new WebSource(sourceXml), RequestResponse = responseXml.ToString() };

            foreach(var parameter in service.Method.Parameters)
            {
                parameter.Value = parameter.DefaultValue;
            }

            var webExecuteHitCount = 0;
            var resourceCatalog = new Mock<IResourceCatalog>();
            var services = new WebServicesMock(resourceCatalog.Object,
                (WebSource source, WebRequestMethod method, string uri, string data, bool error, out ErrorResultTO errors, string[] headers) =>
                {
                    webExecuteHitCount++;
                    errors = new ErrorResultTO();
                    return string.Empty;
                });

            var result = services.Test(service.ToString(), Guid.Empty, Guid.Empty);

            Assert.AreEqual(0, webExecuteHitCount);

            // BUG 9626 - 2013.06.11 - TWR: RecordsetListHelper.ToRecordsetList returns correct number of recordsets now
            Assert.AreEqual(1, result.Recordsets.Count);
            Assert.AreEqual("", result.Recordsets[0].Name);
        }