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 WebServicesDeserializeServiceWithValidJsonExpectedReturnsWebService() { var xml = XmlResource.Fetch("WebService"); var service = new WebService(xml); var services = new WebServicesMock(); var result = services.DeserializeService(service.ToString()); WebServiceTests.VerifyEmbeddedWebService(result as WebService); }
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_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); }