public async Task TemporaryEnableSuccessStaticResultForAction_WithoutConsumerStaticResult_Success() { // Arrange const string actionName = "HTTP"; string correlationId = $"correlationId-{Guid.NewGuid()}"; var headers = new Dictionary <string, string> { { "correlationId", correlationId }, }; using (var logicApp = await LogicAppClient.CreateAsync(ResourceGroup, LogicAppMockingName, Authentication, Logger)) { await using (await logicApp.TemporaryEnableAsync()) { // Act await using (await logicApp.TemporaryEnableSuccessStaticResultAsync(actionName)) { // Assert await logicApp.TriggerAsync(headers); LogicAppAction enabledAction = await PollForLogicAppActionAsync(correlationId, actionName); Assert.Equal(actionName, enabledAction.Name); Assert.Equal("200", enabledAction.Outputs.statusCode.ToString()); Assert.Equal(LogicAppActionStatus.Succeeded, enabledAction.Status); } await logicApp.TriggerAsync(headers); LogicAppAction disabledAction = await PollForLogicAppActionAsync(correlationId, actionName); Assert.NotEmpty(disabledAction.Outputs.headers); } } }
public async Task TemporaryEnableStaticResultsForAction_WithSuccessStaticResult_Success() { // Arrange const string actionName = "HTTP"; string correlationId = $"correlationId-{Guid.NewGuid()}"; var headers = new Dictionary <string, string> { { "correlationId", correlationId }, }; var definition = new StaticResultDefinition { Outputs = new Outputs { Headers = new Dictionary <string, string> { { "testheader", "testvalue" } }, StatusCode = "200", Body = JToken.Parse("{id : 12345, name : 'test body'}") }, Status = "Succeeded" }; var definitions = new Dictionary <string, StaticResultDefinition> { [actionName] = definition }; using (var logicApp = await LogicAppClient.CreateAsync(ResourceGroup, LogicAppMockingName, Authentication, Logger)) { await using (await logicApp.TemporaryEnableAsync()) { // Act await using (await logicApp.TemporaryEnableStaticResultsAsync(definitions)) { // Assert await logicApp.TriggerAsync(headers); LogicAppAction enabledAction = await PollForLogicAppActionAsync(correlationId, actionName); Assert.Equal("200", enabledAction.Outputs.statusCode.ToString()); Assert.Equal("testvalue", enabledAction.Outputs.headers["testheader"].ToString()); Assert.Contains("test body", enabledAction.Outputs.body.ToString()); } await logicApp.TriggerAsync(headers); LogicAppAction disabledAction = await PollForLogicAppActionAsync(correlationId, actionName); Assert.DoesNotContain("test body", disabledAction.Outputs.body.ToString()); } } }
private async Task <LogicAppAction> PollForLogicAppActionAsync(string correlationId, string actionName, string logicAppName) { LogicAppRun logicAppRun = await LogicAppsProvider .LocatedAt(ResourceGroup, logicAppName, Authentication, Logger) .WithStartTime(DateTimeOffset.UtcNow.AddMinutes(-1)) .WithCorrelationId(correlationId) .PollForSingleLogicAppRunAsync(); Assert.True(logicAppRun.Actions.Count() != 0); LogicAppAction logicAppAction1 = logicAppRun.Actions.First(action => action.Name.Equals(actionName)); Assert.NotNull(logicAppAction1); LogicAppAction logicAppAction = logicAppAction1; return(logicAppAction); }
/// <summary> /// Convert to <see cref="LogicAppAction"/>. /// </summary> public static LogicAppAction ToLogicAppAction(WorkflowRunAction workflowRunAction, dynamic input, dynamic output) { Guard.NotNull(param: workflowRunAction, paramName: nameof(workflowRunAction)); Enum.TryParse(value: workflowRunAction.Status, result: out LogicAppActionStatus status); IDictionary <string, string> trackedProperties = DeserializeTrackedProperties(workflowRunAction: workflowRunAction); var logicAppAction = new LogicAppAction( name: workflowRunAction.Name, status: status, error: workflowRunAction.Error, inputs: input, outputs: output, trackedProperties: trackedProperties, startTime: workflowRunAction.StartTime, endTime: workflowRunAction.EndTime); return(logicAppAction); }
public async Task TemporaryUpdateLogicApp_WithUpdatedResponse_ReturnsUpdatedResponse() { // Arrange const string actionName = "Response"; string correlationId = $"correlation-{Guid.NewGuid()}"; var headers = new Dictionary <string, string> { { "correlationId", correlationId }, }; string definition = Configuration.GetLogicAppTriggerUpdateDefinition(); using (var logicApp = await LogicAppClient.CreateAsync(ResourceGroup, TestBaseLogicAppName, Authentication, Logger)) { await using (await logicApp.TemporaryEnableAsync()) { // Act await using (await logicApp.TemporaryUpdateAsync(definition)) { // Assert await logicApp.TriggerAsync(headers); LogicAppAction updatedAction = await PollForLogicAppActionAsync(correlationId, actionName, TestBaseLogicAppName); Assert.Equal("Updated", updatedAction.Outputs.body.response.ToString()); } { await logicApp.TriggerAsync(headers); LogicAppAction updatedAction = await PollForLogicAppActionAsync(correlationId, actionName, TestBaseLogicAppName); Assert.Equal("Original", updatedAction.Outputs.body.response.ToString()); } } } }
private async Task <LogicAppAction> PollForLogicAppActionAsync(string correlationId, string actionName) { LogicAppAction action = await PollForLogicAppActionAsync(correlationId, actionName, LogicAppMockingName); return(action); }