public void WebServicesDeserializeServiceWithInvalidJsonExpectedReturnsNewWebService() { var services = new WebServicesMock(); var result = services.DeserializeService("{'root' : 'hello' }"); Assert.AreEqual(result.ResourceID, Guid.Empty); }
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); }
public void WebServicesDeserializeServiceWithNullXmlExpectedReturnsNewWebService() { var services = new WebServicesMock(); var result = services.DeserializeService(null, "WebService"); Assert.AreEqual(result.ResourceID, Guid.Empty); }
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 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); }
public void WebServicesDeserializeServiceWithValidXmlExpectedReturnsWebService() { var xml = XmlResource.Fetch("WebService"); var services = new WebServicesMock(); var result = services.DeserializeService(xml, "WebService"); WebServiceTests.VerifyEmbeddedWebService(result as WebService); }
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 WebServicesTestWithValidArgsExpectedClearsRecordsFirst() { //------------Setup for test-------------------------- var service = CreateDummyWebService(); //------------Execute Test--------------------------- var services = new WebServicesMock(); services.FetchRecordset(service, true); //------------Assert Results------------------------- Assert.AreEqual(1, services.FetchRecordsetHitCount); }
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 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); }
public void WebServicesDeserializeServiceWithNullJsonExpectedThrowsArgumentNullException() { var services = new WebServicesMock(); services.DeserializeService(null); }
public void WebServicesDeserializeServiceWithNullJsonExpectedThrowsArgumentNullException() { var services = new WebServicesMock(); services.DeserializeService(null); }