Esempio n. 1
0
        public async Task PollForLogicAppRun_ByCorrelationId_Success()
        {
            // Arrange
            string correlationId = $"correlationId-{Guid.NewGuid()}";
            var    headers       = new Dictionary <string, string>
            {
                { "correlationId", correlationId }
            };

            using (var logicApp = await LogicAppClient.CreateAsync(ResourceGroup, LogicAppName, Authentication, Logger))
                await using (await logicApp.TemporaryEnableAsync())
                {
                    Task postTask = logicApp.TriggerAsync(headers);

                    // Act
                    Task <LogicAppRun> pollingTask =
                        LogicAppsProvider.LocatedAt(ResourceGroup, LogicAppName, Authentication, Logger)
                        .WithCorrelationId(correlationId)
                        .PollForSingleLogicAppRunAsync();

                    await Task.WhenAll(pollingTask, postTask);

                    // Assert
                    Assert.NotNull(pollingTask.Result);
                    Assert.Equal(correlationId, pollingTask.Result.CorrelationId);
                }
        }
Esempio n. 2
0
        public async Task PollForLogicAppRun_ByTrackedProperty_DifferentValues_GetsLatest_Success()
        {
            // Arrange
            const string trackedPropertyName   = "trackedproperty";
            string       correlationId         = $"correlationId-{Guid.NewGuid()}";
            string       trackedPropertyValue1 = $"tracked-{Guid.NewGuid()}";
            string       trackedPropertyValue2 = $"tracked-{Guid.NewGuid()}";

            var headers = new Dictionary <string, string>
            {
                { "correlationId", correlationId },
                { "trackedpropertyheader1", trackedPropertyValue1 },
                { "trackedpropertyheader2", trackedPropertyValue2 }
            };

            using (var logicApp = await LogicAppClient.CreateAsync(ResourceGroup, LogicAppName, Authentication))
                await using (await logicApp.TemporaryEnableAsync())
                {
                    Task postTask = logicApp.TriggerAsync(headers);

                    // Act
                    Task <LogicAppRun> pollingTask =
                        LogicAppsProvider.LocatedAt(ResourceGroup, LogicAppName, Authentication, Logger)
                        .WithTrackedProperty(trackedPropertyName, trackedPropertyValue1)
                        .PollForSingleLogicAppRunAsync();

                    await Task.WhenAll(pollingTask, postTask);

                    // Assert
                    Assert.NotNull(pollingTask.Result);
                    Assert.Contains(pollingTask.Result.TrackedProperties, property => property.Value == trackedPropertyValue2);
                }
        }
        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);
        }
Esempio n. 4
0
        public async Task PollForLogicAppRuns_ByTrackedProperty_NumberOfRuns_Success()
        {
            // Arrange
            const string trackedPropertyName = "trackedproperty";
            const int    numberOfRuns        = 2;
            TimeSpan     timeout             = TimeSpan.FromSeconds(40);

            string correlationId        = $"correlationId-{Guid.NewGuid()}";
            var    trackedPropertyValue = Guid.NewGuid().ToString();
            var    headers = new Dictionary <string, string>
            {
                { "correlationId", correlationId },
                { "trackedpropertyheader1", trackedPropertyValue },
                { "trackedpropertyheader2", trackedPropertyValue }
            };

            using (var logicApp = await LogicAppClient.CreateAsync(ResourceGroup, LogicAppName, Authentication))
                await using (await logicApp.TemporaryEnableAsync())
                {
                    // Run logic app twice with the same tracked property.
                    Task postTask1 = logicApp.TriggerAsync(headers);
                    Task postTask2 = logicApp.TriggerAsync(headers);

                    // Act
                    // Poll for a specific number of logic app runs with provided tracked property.
                    Task <IEnumerable <LogicAppRun> > pollingTask =
                        LogicAppsProvider.LocatedAt(ResourceGroup, LogicAppName, Authentication, Logger)
                        .WithTrackedProperty(trackedPropertyName, trackedPropertyValue)
                        .WithTimeout(timeout)
                        .PollForLogicAppRunsAsync(numberOfRuns);

                    await Task.WhenAll(pollingTask, postTask1, postTask2);

                    // Assert
                    Assert.NotNull(pollingTask.Result);
                    Assert.Equal(numberOfRuns, pollingTask.Result.Count());
                    Assert.All(pollingTask.Result, logicAppRun =>
                    {
                        Assert.Contains(logicAppRun.TrackedProperties, property => property.Value == trackedPropertyValue);
                    });
                }
        }
        public async Task RunByNameLogicApp_WithoutTrigger_ReturnsCorrelationId()
        {
            // Arrange
            using (var logicApp = await LogicAppClient.CreateAsync(ResourceGroup, TestBaseLogicAppName, Authentication, Logger))
            {
                await using (await logicApp.TemporaryEnableAsync())
                {
                    // Act
                    await logicApp.RunByNameAsync(triggerName : "manual");

                    // Assert
                    LogicAppRun run = await LogicAppsProvider
                                      .LocatedAt(ResourceGroup, TestBaseLogicAppName, Authentication, Logger)
                                      .WithStartTime(DateTimeOffset.UtcNow.AddMinutes(-1))
                                      .PollForSingleLogicAppRunAsync();

                    Assert.Contains("Response", run.Actions.Select(action => action.Name));
                }
            }
        }
Esempio n. 6
0
        public async Task PollForLogicAppRun_NotMatchedCorrelation_Fails()
        {
            // Arrange
            var headers = new Dictionary <string, string>
            {
                { "correlationId", $"correlationId-{Guid.NewGuid()}" }
            };

            // Act
            Task <LogicAppRun> pollingTask =
                LogicAppsProvider.LocatedAt(ResourceGroup, LogicAppName, Authentication, Logger)
                .WithTimeout(TimeSpan.FromSeconds(5))
                .WithCorrelationId("not-matched-correlation-ID")
                .PollForSingleLogicAppRunAsync();

            using (var logicApp = await LogicAppClient.CreateAsync(ResourceGroup, LogicAppName, Authentication, Logger))
            {
                // Assert
                await logicApp.TriggerAsync(headers);

                await Assert.ThrowsAsync <TimeoutException>(() => pollingTask);
            }
        }
Esempio n. 7
0
        public async Task PollForLogicAppRuns_ByCorrelationId_NumberOfRuns_Success()
        {
            // Arrange
            const int numberOfRuns = 2;
            TimeSpan  timeout      = TimeSpan.FromSeconds(30);

            string correlationId = $"correlationId-{Guid.NewGuid()}";
            var    headers       = new Dictionary <string, string>
            {
                { "correlationId", correlationId }
            };

            using (var logicApp = await LogicAppClient.CreateAsync(ResourceGroup, LogicAppName, Authentication))
                await using (await logicApp.TemporaryEnableAsync())
                {
                    // Run logic app twice with the same correlation id.
                    Task postTask1 = logicApp.TriggerAsync(headers);
                    Task postTask2 = logicApp.TriggerAsync(headers);

                    // Act
                    Task <IEnumerable <LogicAppRun> > pollingTask =
                        LogicAppsProvider.LocatedAt(ResourceGroup, LogicAppName, Authentication, Logger)
                        .WithCorrelationId(correlationId)
                        .WithTimeout(timeout)
                        .PollForLogicAppRunsAsync(numberOfRuns);

                    await Task.WhenAll(pollingTask, postTask1, postTask2);

                    // Assert
                    Assert.Equal(numberOfRuns, pollingTask.Result.Count());
                    Assert.All(pollingTask.Result, logicAppRun =>
                    {
                        Assert.Equal(correlationId, logicAppRun.CorrelationId);
                    });
                }
        }
Esempio n. 8
0
 public void ConstructorWithLogger_WithoutAuthentication_Fails()
 {
     Assert.ThrowsAny <ArgumentException>(
         () => LogicAppsProvider.LocatedAt(ResourceGroup, LogicAppName, authentication: null, logger: Logger));
 }
Esempio n. 9
0
 public void ConstructorWithLogger_WithBlankLogicApp_Fails(string logicApp)
 {
     Assert.Throws <ArgumentException>(
         () => LogicAppsProvider.LocatedAt(ResourceGroup, logicApp, Authentication, Logger));
 }
Esempio n. 10
0
 public void Constructor_WithBlankResourceGroup_Fails(string resourceGroup)
 {
     Assert.Throws <ArgumentException>(
         () => LogicAppsProvider.LocatedAt(resourceGroup, LogicAppName, Authentication));
 }