public void DsfWebGetActivity_ExecutionImpl_ErrorResultTO_ReturnErrors_ToActivity_Success() { //-----------------------Arrange------------------------- const string response = "{\"Message\":\"TEST Error\"}"; 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 TestDsfWebGetActivity { OutputDescription = service.GetOutputDescription(), ResourceID = InArgument <Guid> .FromValue(Guid.Empty), QueryString = "test Query", Headers = new List <INameValue>(), ResponseFromWeb = response, HadErrorMessage = "Some error" }; //-----------------------Act----------------------------- dsfWebGetActivity.TestExecutionImpl(mockEsbChannel.Object, mockDSFDataObject.Object, "Test Inputs", "Test Outputs", out errorResultTO, 0); //-----------------------Assert-------------------------- Assert.AreEqual(1, errorResultTO.FetchErrors().Count); Assert.AreEqual("Some error", errorResultTO.FetchErrors()[0]); } }
public void DsfWebGetActivity_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 TestDsfWebGetActivity { 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"); } }