public void DsfWebDeleteActivity_Execute_WithValidXmlEscaped_ShouldSetVariables() { //------------Setup for test-------------------------- const string response = "<CurrentWeather>" + "<Location><Paris></Location>" + "<Time>May 29, 2013 - 09:00 AM EDT / 2013.05.29 1300 UTC</Time>" + "<Wind>from the NW (320 degrees) at 10 MPH (9 KT) (direction variable):0</Wind>" + "<Visibility><greater than 7 mile(s):0></Visibility>" + "<Temperature> 59 F (15 C)</Temperature>" + "<DewPoint> 41 F (5 C)</DewPoint>" + "<RelativeHumidity> 51%</RelativeHumidity>" + "<Pressure> 29.65 in. Hg (1004 hPa)</Pressure>" + "<Status>Success</Status>" + "</CurrentWeather>"; var environment = new ExecutionEnvironment(); environment.Assign("[[City]]", "PMB", 0); environment.Assign("[[CountryName]]", "South Africa", 0); var dsfWebDeleteActivity = CreateTestDeleteActivity(); var serviceInputs = new List <IServiceInput> { new ServiceInput("CityName", "[[City]]"), new ServiceInput("Country", "[[CountryName]]") }; var serviceOutputs = new List <IServiceOutputMapping> { new ServiceOutputMapping("Location", "[[weather().Location]]", "weather") , new ServiceOutputMapping("Time", "[[weather().Time]]", "weather") , new ServiceOutputMapping("Wind", "[[weather().Wind]]", "weather") , new ServiceOutputMapping("Visibility", "[[Visibility]]", "") }; dsfWebDeleteActivity.Inputs = serviceInputs; dsfWebDeleteActivity.Outputs = serviceOutputs; var serviceXml = XmlResource.Fetch("WebService"); var service = new WebService(serviceXml) { RequestResponse = response }; dsfWebDeleteActivity.OutputDescription = service.GetOutputDescription(); dsfWebDeleteActivity.ResponseFromWeb = response; var dataObjectMock = new Mock <IDSFDataObject>(); dataObjectMock.Setup(o => o.Environment).Returns(environment); dataObjectMock.Setup(o => o.EsbChannel).Returns(new Mock <IEsbChannel>().Object); dsfWebDeleteActivity.ResourceID = InArgument <Guid> .FromValue(Guid.Empty); dsfWebDeleteActivity.QueryString = ""; //dsfWebPostActivity.PostData = ""; dsfWebDeleteActivity.SourceId = Guid.Empty; dsfWebDeleteActivity.Headers = new List <INameValue>(); //------------Execute Test--------------------------- dsfWebDeleteActivity.Execute(dataObjectMock.Object, 0); //------------Assert Results------------------------- Assert.IsNotNull(dsfWebDeleteActivity.OutputDescription); var visibility = ExecutionEnvironment.WarewolfEvalResultToString(environment.Eval("[[Visibility]]", 0)); Assert.AreEqual("<greater than 7 mile(s):0>", visibility); var location = ExecutionEnvironment.WarewolfEvalResultToString(environment.Eval("[[weather().Location]]", 0)); Assert.AreEqual("<Paris>", location); var time = ExecutionEnvironment.WarewolfEvalResultToString(environment.Eval("[[weather().Time]]", 0)); Assert.AreEqual("May 29, 2013 - 09:00 AM EDT / 2013.05.29 1300 UTC", time); var wind = ExecutionEnvironment.WarewolfEvalResultToString(environment.Eval("[[weather().Wind]]", 0)); Assert.AreEqual("from the NW (320 degrees) at 10 MPH (9 KT) (direction variable):0", wind); }
private ErrorCode WriteResourceFail(Enums.ResourceType resourceType, XmlResource resource) { return(PublicApiAdapter.CreateAdapterForDefaultConnection().WriteFail(resource, cleanupAction: null)); }
public static void ClassInitialize(TestContext context) { _connectionXml = XmlResource.Fetch("ServerConnection2"); _connection = new Connection(_connectionXml); }
private byte[] GetByteArray(Enums.ResourceType resourceType, XmlResource resource, string fieldAlias, string insertType) { resource.DictionaryValues[fieldAlias] = Util.GetUniqueString(50, false); string origin = string.Empty; switch (resourceType) { case Enums.ResourceType.Activity: origin = XmlHelper.GenerateXMLString <Activity>(new List <Activity> { resource as Activity }); break; case Enums.ResourceType.Candidate: origin = XmlHelper.GenerateXMLString <Candidate>(new List <Candidate> { resource as Candidate }); break; case Enums.ResourceType.Client: origin = XmlHelper.GenerateXMLString <Client>(new List <Client> { resource as Client }); break; case Enums.ResourceType.Contract: origin = XmlHelper.GenerateXMLString <Contract>(new List <Contract> { resource as Contract }); break; case Enums.ResourceType.Job: origin = XmlHelper.GenerateXMLString <Job>(new List <Job> { resource as Job }); break; case Enums.ResourceType.Process: origin = XmlHelper.GenerateXMLString <Process>(new List <Process> { resource as Process }); break; case Enums.ResourceType.Recruiter: origin = XmlHelper.GenerateXMLString <Recruiter>(new List <Recruiter> { resource as Recruiter }); break; case Enums.ResourceType.Resume: origin = XmlHelper.GenerateXMLString <Resume>(new List <Resume> { resource as Resume }); break; case Enums.ResourceType.Sales: origin = XmlHelper.GenerateXMLString <Sales>(new List <Sales> { resource as Sales }); break; } int endOfField = origin.IndexOf($"</{fieldAlias}>"); byte[] head = Encoding.UTF8.GetBytes(origin.Substring(0, endOfField)); byte[] tail = Encoding.UTF8.GetBytes(origin.Substring(endOfField, origin.Length - endOfField)); byte[] specialCharacter = GetSpecialCharacter(insertType); return(head.Concat(specialCharacter.Concat(tail)).ToArray()); }
private ErrorCode WriteResourceFail(XmlResource resource) { return(PublicApiAdapter.CreateAdapterForDefaultConnection().WriteFail(resource, cleaner.DeleteMany)); }
public void GetDebugInputs_GivenMockEnvironment_ShouldAddDebugInputItems() { //---------------Set up test pack------------------- const string response = "{\"Location\": \"Paris\",\"Time\": \"May 29, 2013 - 09:00 AM EDT / 2013.05.29 1300 UTC\"," + "\"Wind\": \"from the NW (320 degrees) at 10 MPH (9 KT) (direction variable):0\"," + "\"Visibility\": \"greater than 7 mile(s):0\"," + "\"Temperature\": \"59 F (15 C)\"," + "\"DewPoint\": \"41 F (5 C)\"," + "\"RelativeHumidity\": \"51%\"," + "\"Pressure\": \"29.65 in. Hg (1004 hPa)\"," + "\"Status\": \"Success\"" + "}"; var environment = new ExecutionEnvironment(); environment.Assign("[[City]]", "PMB", 0); environment.Assign("[[CountryName]]", "South Africa", 0); environment.Assign("[[Post]]", "Some data", 0); var dsfWebPostActivity = new TestDsfWebPostActivity { Headers = new List <INameValue> { new NameValue("Header 1", "[[City]]") }, QueryString = "http://www.testing.com/[[CountryName]]", PostData = "This is post:[[Post]]" }; var serviceOutputs = new List <IServiceOutputMapping> { new ServiceOutputMapping("Location", "[[weather().Location]]", "weather"), new ServiceOutputMapping("Time", "[[weather().Time]]", "weather"), new ServiceOutputMapping("Wind", "[[weather().Wind]]", "weather"), new ServiceOutputMapping("Visibility", "[[Visibility]]", "") }; dsfWebPostActivity.Outputs = serviceOutputs; var serviceXml = XmlResource.Fetch("WebService"); var service = new WebService(serviceXml) { RequestResponse = response }; dsfWebPostActivity.OutputDescription = service.GetOutputDescription(); dsfWebPostActivity.ResponseFromWeb = response; var dataObjectMock = new Mock <IDSFDataObject>(); dataObjectMock.Setup(o => o.Environment).Returns(environment); dataObjectMock.Setup(o => o.EsbChannel).Returns(new Mock <IEsbChannel>().Object); dsfWebPostActivity.ResourceID = InArgument <Guid> .FromValue(Guid.Empty); var cat = new Mock <IResourceCatalog>(); var src = new WebSource { Address = "www.example.com" }; cat.Setup(a => a.GetResource <WebSource>(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(src); dsfWebPostActivity.ResourceCatalog = cat.Object; //---------------Assert Precondition---------------- Assert.IsNotNull(environment); Assert.IsNotNull(dsfWebPostActivity); //---------------Execute Test ---------------------- var debugInputs = dsfWebPostActivity.GetDebugInputs(environment, 0); //---------------Test Result ----------------------- Assert.IsNotNull(debugInputs); Assert.AreEqual(4, debugInputs.Count); }
private ErrorCode WriteResourceFail(Enums.ResourceType resourceType, XmlResource resource) { return(PublicApiAdapter.CreateAdapterForDefaultConnection().WriteFail(resource, (resourceType == Enums.ResourceType.Process ? processCleaner : cleaner).DeleteMany)); }
public void ConstructorWithValidXmlArgumentExpectedInitializesAllProperties() { var config = new Configuration.Settings.Configuration(XmlResource.Fetch("Settings")); ValidateInitializesAllProperties(config); }
public void ConstructorWithValidXmlNullWebServerUriArgumentExpectedThrowsArgumentNullException() { var config = new Configuration.Settings.Configuration(XmlResource.Fetch("Settings")); ValidateInitializesAllProperties(config); }
public void HasErrorReturnsFalse() { var config = new Configuration.Settings.Configuration(XmlResource.Fetch("Settings")); Assert.IsFalse(config.HasError); }
public void LoggingSettingChangedExpectsHasChangesFalseWhenInitializating() { var config = new Configuration.Settings.Configuration(XmlResource.Fetch("Settings")); Assert.IsFalse(config.HasChanges); }
private static int GetUserValue(XmlResource result, string fieldAlias) { return(int.Parse(((result.DictionaryValues[$"{fieldAlias}"] as XmlResource).DictionaryValues["User"] as XmlResource).DictionaryValues["User.P_Id"].ToString())); }
public void WebGetActivity_ExecutionImpl_ResponseManager_PushResponseIntoEnvironment_GivenJsonResponse_MappedToRecodSet_ShouldSucess() { //-----------------------Arrange------------------------- const string json = "{\"Messanger\":\"jSon response from the request\"}"; var response = Convert.ToBase64String(json.ToBytesArray()); const string mappingFrom = "mapFrom"; const string recordSet = "recset"; const string mapTo = "mapTo"; const string variableNameMappingTo = "[[recset().mapTo]]"; var environment = new ExecutionEnvironment(); var mockEsbChannel = new Mock <IEsbChannel>(); var mockDSFDataObject = new Mock <IDSFDataObject>(); var mockExecutionEnvironment = new Mock <IExecutionEnvironment>(); var errorResultTO = new ErrorResultTO(); using (var service = new WebService(XmlResource.Fetch("WebService")) { RequestResponse = response }) { mockDSFDataObject.Setup(o => o.Environment).Returns(environment); mockDSFDataObject.Setup(o => o.EsbChannel).Returns(new Mock <IEsbChannel>().Object); var dsfWebGetActivity = new TestWebPostActivity { OutputDescription = service.GetOutputDescription(), ResourceID = InArgument <Guid> .FromValue(Guid.Empty), QueryString = "test Query", Headers = new List <INameValue>(), ResponseFromWeb = response, IsObject = false, Outputs = new List <IServiceOutputMapping> { { new ServiceOutputMapping { MappedFrom = mappingFrom, MappedTo = mapTo, RecordSetName = recordSet } } } }; //-----------------------Act----------------------------- dsfWebGetActivity.TestExecutionImpl(mockEsbChannel.Object, mockDSFDataObject.Object, "Test Inputs", "Test Outputs", out errorResultTO, 0); //-----------------------Assert-------------------------- Assert.IsFalse(errorResultTO.HasErrors()); //assert first DataSourceShapes var resourceManager = dsfWebGetActivity.ResponseManager; var outputDescription = resourceManager.OutputDescription; var dataShapes = outputDescription.DataSourceShapes; var paths = dataShapes.First().Paths; Assert.IsNotNull(outputDescription); Assert.AreEqual("Messanger", paths.First().ActualPath); Assert.AreEqual("Messanger", paths.First().DisplayPath); Assert.AreEqual(variableNameMappingTo, paths.First().OutputExpression); Assert.AreEqual("jSon response from the request", paths.First().SampleData); //assert execution environment var envirVariable = environment.Eval(recordSet, 0); var ress = envirVariable as CommonFunctions.WarewolfEvalResult.WarewolfAtomResult; Assert.IsNotNull(envirVariable); Assert.IsFalse(ress.Item.IsNothing, "Item should contain the recset mapped to the messanger key"); } }
public void TestReadValidInputWithScale(Enums.ResourceType resourceType, string fieldScale, string precision, string scale) { decimal valueInput = decimal.Parse(precision + scale); decimal valueOuput = GetPrecisionAfterScale(precision, scale, fieldScale); XmlResource resource = CreateResourceInstance(resourceType); string fieldAlias = customFields.Data[$"{resourceType}-{fieldScale}"].Field.ToAlias(); resource.DictionaryValues[fieldAlias] = valueInput; string id = WriteResource(resourceType, resource); Assert.That(id, Is.Not.Null.And.Not.Empty, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType)); //Read & verify the field's value string resourceName = resourceType == Enums.ResourceType.Candidate ? "Person" : resourceType.ToString(); Dictionary <string, object> urlParameter = new Dictionary <string, object>() { { "partition", AuthenticationInfoProvider.Current.DefaultPartition }, { "condition", string.Format("{0}.P_Id:eq={1}", resourceName, id) }, { "field", fieldAlias } }; switch (resourceType) { case Enums.ResourceType.Activity: ReadData <Activity>(urlParameter, fieldAlias, valueOuput); break; case Enums.ResourceType.Client: ReadData <Client>(urlParameter, fieldAlias, valueOuput); break; case Enums.ResourceType.Candidate: ReadData <Candidate>(urlParameter, fieldAlias, valueOuput); break; case Enums.ResourceType.Contract: ReadData <Contract>(urlParameter, fieldAlias, valueOuput); break; case Enums.ResourceType.Job: ReadData <Job>(urlParameter, fieldAlias, valueOuput); break; case Enums.ResourceType.Process: ReadData <Process>(urlParameter, fieldAlias, valueOuput); break; case Enums.ResourceType.Recruiter: ReadData <Recruiter>(urlParameter, fieldAlias, valueOuput); break; case Enums.ResourceType.Resume: ReadData <Resume>(urlParameter, fieldAlias, valueOuput); break; case Enums.ResourceType.Sales: ReadData <Sales>(urlParameter, fieldAlias, valueOuput); break; } }
private string WriteResource(Enums.ResourceType resourceType, XmlResource resource) { return(PublicApiAdapter.CreateAdapterForDefaultConnection().WriteSuccess(resource, cleaner.Delete)); }
public void DsfWebPutActivity_Execute_WithValidTextResponse_ShouldSetVariables() { //------------Setup for test-------------------------- const string response = "{\"Location\": \"Paris\",\"Time\": \"May 29, 2013 - 09:00 AM EDT / 2013.05.29 1300 UTC\"," + "\"Wind\": \"from the NW (320 degrees) at 10 MPH (9 KT) (direction variable):0\"," + "\"Visibility\": \"greater than 7 mile(s):0\"," + "\"Temperature\": \"59 F (15 C)\"," + "\"DewPoint\": \"41 F (5 C)\"," + "\"RelativeHumidity\": \"51%\"," + "\"Pressure\": \"29.65 in. Hg (1004 hPa)\"," + "\"Status\": \"Success\"" + "}"; var environment = new ExecutionEnvironment(); environment.Assign("[[City]]", "PMB", 0); environment.Assign("[[CountryName]]", "South Africa", 0); var DsfWebGetActivity = new TestDsfWebGetActivity(); DsfWebGetActivity.ResourceCatalog = new Mock <IResourceCatalog>().Object; var serviceInputs = new List <IServiceInput> { new ServiceInput("CityName", "[[City]]"), new ServiceInput("Country", "[[CountryName]]") }; var serviceOutputs = new List <IServiceOutputMapping> { new ServiceOutputMapping("Response", "[[Response]]", "") }; DsfWebGetActivity.Inputs = serviceInputs; DsfWebGetActivity.Outputs = serviceOutputs; var serviceXml = XmlResource.Fetch("WebService"); var service = new WebService(serviceXml) { RequestResponse = response }; DsfWebGetActivity.OutputDescription = service.GetOutputDescription(); DsfWebGetActivity.ResponseFromWeb = response; var dataObjectMock = new Mock <IDSFDataObject>(); dataObjectMock.Setup(o => o.Environment).Returns(environment); dataObjectMock.Setup(o => o.EsbChannel).Returns(new Mock <IEsbChannel>().Object); DsfWebGetActivity.ResourceID = InArgument <Guid> .FromValue(Guid.Empty); DsfWebGetActivity.QueryString = ""; DsfWebGetActivity.SourceId = Guid.Empty; DsfWebGetActivity.Headers = new List <INameValue>(); DsfWebGetActivity.OutputDescription = new OutputDescription(); DsfWebGetActivity.OutputDescription.DataSourceShapes.Add(new DataSourceShape() { Paths = new List <IPath>() { new StringPath() { ActualPath = "[[Response]]", OutputExpression = "[[Response]]" } } }); //------------Execute Test--------------------------- DsfWebGetActivity.Execute(dataObjectMock.Object, 0); //------------Assert Results------------------------- Assert.IsNotNull(DsfWebGetActivity.OutputDescription); Assert.AreEqual(response, ExecutionEnvironment.WarewolfEvalResultToString(environment.Eval("[[Response]]", 0))); }
private XmlResource CreateUpdatedResource(Enums.ResourceType resourceType, string id, string fieldAlias, string fieldValue) { XmlResource result = null; switch (resourceType) { case Enums.ResourceType.Client: result = new Client() { Id = id }; result.DictionaryValues[fieldAlias] = fieldValue; break; case Enums.ResourceType.Activity: result = new Activity() { Id = id }; result.DictionaryValues[fieldAlias] = fieldValue; break; case Enums.ResourceType.Sales: result = new Sales() { Id = id }; result.DictionaryValues[fieldAlias] = fieldValue; break; case Enums.ResourceType.Contract: result = new Contract() { Id = id }; result.DictionaryValues[fieldAlias] = fieldValue; break; case Enums.ResourceType.Process: result = new Process() { Id = id }; result.DictionaryValues[fieldAlias] = fieldValue; break; case Enums.ResourceType.Job: result = new Job() { Id = id }; result.DictionaryValues[fieldAlias] = fieldValue; break; case Enums.ResourceType.Recruiter: result = new Recruiter() { Id = id }; result.DictionaryValues[fieldAlias] = fieldValue; break; case Enums.ResourceType.Resume: result = new Resume() { Id = id }; result.DictionaryValues[fieldAlias] = fieldValue; break; case Enums.ResourceType.Candidate: result = new Candidate() { Id = id }; result.DictionaryValues[fieldAlias] = fieldValue; break; } return(result); }
public void DsfWebPostActivity_Execute_WithInValidWebResponse_ShouldError() { //------------Setup for test-------------------------- const string response = "{\"Location\": \"Paris\",\"Time\": \"May 29, 2013 - 09:00 AM EDT / 2013.05.29 1300 UTC\"," + "\"Wind\": \"from the NW (320 degrees) at 10 MPH (9 KT) (direction variable):0\"," + "\"Visibility\": \"greater than 7 mile(s):0\"," + "\"Temperature\": \"59 F (15 C)\"," + "\"DewPoint\": \"41 F (5 C)\"," + "\"RelativeHumidity\": \"51%\"," + "\"Pressure\": \"29.65 in. Hg (1004 hPa)\"," + "\"Status\": \"Success\"" + "}"; const string invalidResponse = "{\"Location\" \"Paris\",\"Time\": \"May 29, 2013 - 09:00 AM EDT / 2013.05.29 1300 UTC\"," + "\"Wind\": \"from the NW (320 degrees) at 10 MPH (9 KT) (direction variable):0\"," + "\"Visibility\": \"greater than 7 mile(s):0\"," + "\"Temperature\": \"59 F (15 C)\"," + "\"DewPoint\": \"41 F (5 C)\"," + "\"RelativeHumidity\": \"51%\"," + "\"Pressure\": \"29.65 in. Hg (1004 hPa)\"," + "\"Status\": \"Success\"" + ""; var environment = new ExecutionEnvironment(); environment.Assign("[[City]]", "PMB", 0); environment.Assign("[[CountryName]]", "South Africa", 0); var dsfWebPostActivity = new TestDsfWebPostActivity(); dsfWebPostActivity.ResourceCatalog = new Mock <IResourceCatalog>().Object; var serviceInputs = new List <IServiceInput> { new ServiceInput("CityName", "[[City]]"), new ServiceInput("Country", "[[CountryName]]") }; var serviceOutputs = new List <IServiceOutputMapping> { new ServiceOutputMapping("Location", "[[weather().Location]]", "weather"), new ServiceOutputMapping("Time", "[[weather().Time]]", "weather"), new ServiceOutputMapping("Wind", "[[weather().Wind]]", "weather"), new ServiceOutputMapping("Visibility", "[[Visibility]]", "") }; dsfWebPostActivity.Inputs = serviceInputs; dsfWebPostActivity.Outputs = serviceOutputs; var serviceXml = XmlResource.Fetch("WebService"); var service = new WebService(serviceXml) { RequestResponse = response }; dsfWebPostActivity.OutputDescription = service.GetOutputDescription(); dsfWebPostActivity.ResponseFromWeb = invalidResponse; var dataObjectMock = new Mock <IDSFDataObject>(); dataObjectMock.Setup(o => o.Environment).Returns(environment); dataObjectMock.Setup(o => o.EsbChannel).Returns(new Mock <IEsbChannel>().Object); dsfWebPostActivity.ResourceID = InArgument <Guid> .FromValue(Guid.Empty); dsfWebPostActivity.QueryString = ""; dsfWebPostActivity.PostData = ""; dsfWebPostActivity.SourceId = Guid.Empty; dsfWebPostActivity.Headers = new List <INameValue>(); //------------Execute Test--------------------------- dsfWebPostActivity.Execute(dataObjectMock.Object, 0); //------------Assert Results------------------------- Assert.IsNotNull(dsfWebPostActivity.OutputDescription); Assert.AreEqual(1, environment.Errors.Count); StringAssert.Contains(environment.Errors.ToList()[0], "Invalid character after parsing property name"); }