Inheritance: Dev2.Runtime.ServiceModel.WebServices
Exemplo n.º 1
0
        public void WebServicesDeserializeServiceWithInvalidJsonExpectedReturnsNewWebService()
        {
            var services = new WebServicesMock();
            var result   = services.DeserializeService("{'root' : 'hello' }");

            Assert.AreEqual(result.ResourceID, Guid.Empty);
        }
Exemplo 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);
        }
Exemplo n.º 3
0
        public void WebServicesDeserializeServiceWithNullXmlExpectedReturnsNewWebService()
        {
            var services = new WebServicesMock();
            var result   = services.DeserializeService(null, "WebService");

            Assert.AreEqual(result.ResourceID, Guid.Empty);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        public void WebServicesDeserializeServiceWithValidXmlExpectedReturnsWebService()
        {
            var xml = XmlResource.Fetch("WebService");

            var services = new WebServicesMock();
            var result   = services.DeserializeService(xml, "WebService");

            WebServiceTests.VerifyEmbeddedWebService(result as WebService);
        }
Exemplo n.º 8
0
        public void WebServicesTestWithValidArgsAndRecordsetFieldsExpectedDoesNotAddRecordsetFields()
        {
            //------------Setup for test--------------------------
            var service = CreateDummyWebService();
            //------------Execute Test---------------------------
            var services = new WebServicesMock();

            services.FetchRecordset(service, false);
            //------------Assert Results-------------------------
            Assert.IsFalse(services.FetchRecordsetAddFields);
        }
Exemplo n.º 9
0
        public void WebServicesTestWithValidArgsExpectedClearsRecordsFirst()
        {
            //------------Setup for test--------------------------
            var service = CreateDummyWebService();
            //------------Execute Test---------------------------
            var services = new WebServicesMock();

            services.FetchRecordset(service, true);
            //------------Assert Results-------------------------
            Assert.AreEqual(1, services.FetchRecordsetHitCount);
        }
Exemplo n.º 10
0
        public void WebServicesTestWithValidArgsAndNoRecordsetFieldsExpectedAddsRecordsetFields()
        {
            //------------Setup for test--------------------------
            var service = CreateDummyWebService();
            //service.Recordset.Fields.Clear();
            //------------Execute Test---------------------------
            //------------Assert Results-------------------------
            var services = new WebServicesMock();

            services.FetchRecordset(service, true);
            Assert.IsTrue(services.FetchRecordsetAddFields);
        }
Exemplo n.º 11
0
        public void Webservice_Test_WhenJsonPathNotSet_ExpectNoShapedData()
        {
            //------------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)
            };

            var services = new WebServicesMock();

            service.RequestResponse = response;

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

            //------------Assert Results-------------------------
            Assert.AreEqual(null, result.JsonPathResult);
        }
 public void WebServicesDeserializeServiceWithInvalidJsonExpectedReturnsNewWebService()
 {
     var services = new WebServicesMock();
     var result = services.DeserializeService("{'root' : 'hello' }");
     Assert.AreEqual(result.ResourceID, Guid.Empty);
 }
        public void Webservice_Test_WhenJsonPathNotSet_ExpectNoShapedData()
        {
            //------------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) };

            var services = new WebServicesMock();

            service.RequestResponse = response;

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

            //------------Assert Results-------------------------
            Assert.AreEqual(null, result.JsonPathResult);
        }
        public void WebServicesDeserializeServiceWithValidXmlExpectedReturnsWebService()
        {
            var xml = XmlResource.Fetch("WebService");

            var services = new WebServicesMock();
            var result = services.DeserializeService(xml, ResourceType.WebService);

            WebServiceTests.VerifyEmbeddedWebService(result as WebService);
        }
        public void WebServicesDeserializeServiceWithNullXmlExpectedReturnsNewWebService()
        {
            var services = new WebServicesMock();
            var result = services.DeserializeService(null, ResourceType.WebService);

            Assert.AreEqual(result.ResourceID, Guid.Empty);
        }
        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);
        }
 public void WebServicesTestWithValidArgsAndRecordsetFieldsExpectedDoesNotAddRecordsetFields()
 {
     //------------Setup for test--------------------------
     var service = CreateDummyWebService();
     //------------Execute Test---------------------------
     var services = new WebServicesMock();
     services.FetchRecordset(service, false);
     //------------Assert Results-------------------------
     Assert.IsFalse(services.FetchRecordsetAddFields);
 }
 public void WebServicesTestWithValidArgsAndNoRecordsetFieldsExpectedAddsRecordsetFields()
 {
     //------------Setup for test--------------------------
     var service = CreateDummyWebService();
     //service.Recordset.Fields.Clear();
     //------------Execute Test---------------------------
     //------------Assert Results-------------------------
     var services = new WebServicesMock();
     services.FetchRecordset(service, true);
     Assert.IsTrue(services.FetchRecordsetAddFields);
 }
 public void WebServicesTestWithValidArgsExpectedClearsRecordsFirst()
 {
     //------------Setup for test--------------------------
     var service = CreateDummyWebService();
     //------------Execute Test---------------------------
     var services = new WebServicesMock();
     services.FetchRecordset(service, true);
     //------------Assert Results-------------------------
     Assert.AreEqual(1, services.FetchRecordsetHitCount);
 }
Exemplo n.º 21
0
        public void WebServicesDeserializeServiceWithNullJsonExpectedThrowsArgumentNullException()
        {
            var services = new WebServicesMock();

            services.DeserializeService(null);
        }
 public void WebServicesDeserializeServiceWithNullJsonExpectedThrowsArgumentNullException()
 {
     var services = new WebServicesMock();
     services.DeserializeService(null);
 }