588 references to Snapshot
Aspire.Hosting (66)
ApplicationModel\CommandsConfigurationExtensions.cs (3)
225preRebuildStates[name] = evt.Snapshot.State?.Text; 281KnownResourceStates.TerminalStates.Contains(evt.Snapshot.State?.Text)) 283exitCode = evt.Snapshot.ExitCode;
ApplicationModel\ResourceNotificationService.cs (19)
133re => re.Snapshot.State?.Text is { Length: > 0 } stateText && targetStates.Contains(stateText, StringComparers.ResourceState), 137var finalState = resourceEvent.Snapshot.State!.Text!; 157re => re.ResourceId == resourceId && re.Snapshot.HealthStatus == HealthStatus.Healthy, 167re => re.ResourceId == resourceId && re.Snapshot.ResourceReadyEvent is not null, 173await resourceEvent.Snapshot.ResourceReadyEvent!.EventTask.WaitAsync(cancellationToken).ConfigureAwait(false); 258re => ShouldYieldHealthyWait(waitBehavior, re.Snapshot), 263if (resourceEvent.Snapshot.HealthStatus != HealthStatus.Healthy) 273re => re.ResourceId == resourceEvent.ResourceId && re.Snapshot.ResourceReadyEvent is not null, 279await resourceEvent.Snapshot.ResourceReadyEvent!.EventTask.WaitAsync(cancellationToken).ConfigureAwait(false); 329re => re.ResourceId == resourceId && IsKnownTerminalState(re.Snapshot), 333var snapshot = resourceEvent.Snapshot; 393re => re.ResourceId == resourceId && IsContinuableState(waitBehavior, re.Snapshot), 397var snapshot = resourceEvent.Snapshot; 796if (versionsSeen.TryGetValue(item.ResourceId, out var maxVersionSeen) && item.Snapshot.Version <= maxVersionSeen) 1290if (TryGetCurrentState(resourceName, out var evt) && evt.Snapshot != null) 1292var snapshot = evt.Snapshot; 1332error.Append(CultureInfo.InvariantCulture, $" - {dependencyName}: State = {dependencyEvent.Snapshot.State?.Text ?? "(null)"}"); 1333error.Append(CultureInfo.InvariantCulture, $", Health = {dependencyEvent.Snapshot.HealthStatus?.ToString() ?? "(null)"}"); 1334if (dependencyEvent.Snapshot.ExitCode is { } exitCode)
Ats\NotificationExports.cs (4)
155State = resourceEvent.Snapshot.State?.Text, 156StateStyle = resourceEvent.Snapshot.State?.Style, 157HealthStatus = resourceEvent.Snapshot.HealthStatus?.ToString(), 158ExitCode = resourceEvent.Snapshot.ExitCode
Backchannel\AppHostRpcTarget.cs (4)
145var healthStatus = CustomResourceSnapshot.ComputeHealthStatus(resourceEvent.Snapshot.HealthReports, resourceEvent.Snapshot.State?.Text); 150Type = resourceEvent.Snapshot.ResourceType, 151State = resourceEvent.Snapshot.State?.Text ?? "Unknown",
Backchannel\AuxiliaryBackchannelRpcTarget.cs (18)
681re => ResourceNotificationService.ShouldYieldHealthyWait(WaitBehavior.StopOnResourceUnavailable, re.Snapshot), 685if (resourceEvent.Snapshot.HealthStatus != HealthStatus.Healthy) 693re => re.Snapshot.ResourceReadyEvent is not null, 697await resourceEvent.Snapshot.ResourceReadyEvent!.EventTask.WaitAsync(cancellationToken).ConfigureAwait(false); 702State = resourceEvent.Snapshot.State?.Text, 703HealthStatus = resourceEvent.Snapshot.HealthStatus?.ToString() 712re => re.Snapshot.State?.Text == KnownResourceStates.Running || 713KnownResourceStates.TerminalStates.Contains(re.Snapshot.State?.Text, StringComparers.ResourceState) || 714string.Equals(re.Snapshot.State?.Style, KnownResourceStateStyles.Error, StringComparisons.ResourceState) || 715re.Snapshot.ExitCode is not null, 719var state = resourceEvent.Snapshot.State?.Text; 726HealthStatus = resourceEvent.Snapshot.HealthStatus?.ToString(), 736re => KnownResourceStates.TerminalStates.Contains(re.Snapshot.State?.Text) || re.Snapshot.ExitCode is not null, 743State = resourceEvent.Snapshot.State?.Text, 744HealthStatus = resourceEvent.Snapshot.HealthStatus?.ToString() 1052var snapshot = resourceEvent.Snapshot; 1742return notificationService.TryGetCurrentState(resourceName, out var resourceEvent) && resourceEvent.Snapshot.IsHidden;
Dashboard\DashboardServiceData.cs (1)
100var snapshot = CreateResourceSnapshot(@event.Resource, @event.ResourceId, timestamp, @event.Snapshot);
Devcontainers\Codespaces\CodespacesResourceUrlRewriterService.cs (2)
32foreach (var originalUrlSnapshot in resourceEvent.Snapshot.Urls) 57var transformedUrls = from originalUrl in resourceEvent.Snapshot.Urls
Diagnostics\ProfilingTelemetry.cs (1)
1098var snapshot = resourceEvent.Snapshot;
DistributedApplication.cs (1)
820results.Add(new() { Resource = resource, Snapshot = resourceEvent?.Snapshot });
Health\ResourceHealthCheckService.cs (8)
42if (resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running) 73else if (KnownResourceStates.TerminalStates.Contains(resourceEvent.Snapshot.State?.Text)) 85&& KnownResourceStates.TerminalStates.Contains(evt.Snapshot.State?.Text)); 191if (ContainsAnyHealthReportChange(report, currentEvent.Snapshot.HealthReports)) 393if (currentEvent.Snapshot.Version <= previousEvent.Snapshot.Version) 397if (currentEvent.Snapshot.State?.Text == previousEvent.Snapshot.State?.Text)
Lifecycle\TerminalHostFailureDiagnosticService.cs (3)
66var state = evt.Snapshot.State?.Text; 75&& evt.Snapshot.ExitCode is 0) 85await SurfaceFailureAsync(host, evt.Snapshot, stoppingToken).ConfigureAwait(false);
Orchestrator\ApplicationOrchestrator.cs (2)
162if (e.Snapshot.State?.Text == KnownResourceStates.Waiting) 586previousState = previousResourceEvent.Snapshot.State?.Text;
Aspire.Hosting.Azure (5)
AzureProvisioningController.cs (5)
2161environmentEvent.Snapshot.State?.Text != KnownResourceStates.Running) 3143return resourceEvent.Snapshot.Properties 3387return resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running; 3835string.Equals(currentEvent.Snapshot.State?.Text, state, StringComparison.Ordinal); 3841currentEvent.Snapshot.State is { Text: { } stateText } currentState &&
Aspire.Hosting.Azure.Tests (139)
AzureBicepProvisionerTests.cs (29)
80var parentProperty = resourceEvent.Snapshot.Properties.FirstOrDefault(x => x.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 751AssertHighlightedContextProperty(resourceEvent.Snapshot.Properties, "azure.subscription.id", "12345678-1234-1234-1234-123456789012", AzureProvisioningStrings.ContextPropertySubscriptionIdDisplayName); 752AssertHighlightedContextProperty(resourceEvent.Snapshot.Properties, "azure.resource.group", "test-rg", AzureProvisioningStrings.ContextPropertyResourceGroupDisplayName); 753AssertHighlightedContextProperty(resourceEvent.Snapshot.Properties, "azure.tenant.id", "87654321-4321-4321-4321-210987654321", AzureProvisioningStrings.ContextPropertyTenantIdDisplayName); 754AssertHighlightedContextProperty(resourceEvent.Snapshot.Properties, "azure.tenant.domain", "testdomain.onmicrosoft.com", AzureProvisioningStrings.ContextPropertyTenantDomainDisplayName); 755AssertHighlightedContextProperty(resourceEvent.Snapshot.Properties, "azure.location", "westus3", AzureProvisioningStrings.ContextPropertyLocationDisplayName); 756Assert.Equal("/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/test-rg/providers/Microsoft.Resources/deployments/storage", resourceEvent.Snapshot.Properties.Single(p => p.Name == CustomResourceKnownProperties.Source).Value?.ToString()); 785Assert.Equal("87654321-4321-4321-4321-210987654321", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.tenant.id").Value?.ToString()); 786Assert.Equal("/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/test-rg/providers/Microsoft.Resources/deployments/storage2", resourceEvent.Snapshot.Properties.Single(p => p.Name == CustomResourceKnownProperties.Source).Value?.ToString()); 823Assert.Equal("87654321-4321-4321-4321-210987654321", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.tenant.id").Value?.ToString()); 824Assert.Equal(expectedDeploymentId, resourceEvent.Snapshot.Properties.Single(p => p.Name == CustomResourceKnownProperties.Source).Value?.ToString()); 825Assert.Equal(BicepProvisioner.GetDeploymentUrl(new ResourceIdentifier(expectedDeploymentId)), resourceEvent.Snapshot.Urls.Single(u => u.Name == "deployment").Url); 937Assert.Equal("12345678-1234-1234-1234-123456789012", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.subscription.id").Value?.ToString()); 938Assert.Equal("test-rg", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.resource.group").Value?.ToString()); 939Assert.Equal("87654321-4321-4321-4321-210987654321", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.tenant.id").Value?.ToString()); 940Assert.Equal("microsoft.onmicrosoft.com", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.tenant.domain").Value?.ToString()); 941Assert.Equal("westus2", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.location").Value?.ToString()); 942Assert.Equal("/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/test-rg/providers/Microsoft.Resources/deployments/storage2", resourceEvent.Snapshot.Properties.Single(p => p.Name == CustomResourceKnownProperties.Source).Value?.ToString()); 988Assert.Equal("scoped-rg", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.resource.group").Value?.ToString()); 1179Assert.Equal("Azure deployment failed", resourceEvent.Snapshot.State?.Text); 1181resourceEvent.Snapshot.Properties, 1225resourceEvent.Snapshot.Properties.Where(static property => 1294Assert.Equal("Azure deployment failed", resourceEvent.Snapshot.State?.Text); 1295Assert.DoesNotContain(resourceEvent.Snapshot.Properties, p => p.Name.StartsWith("azure.deployment.operations.", StringComparison.Ordinal)); 1296Assert.Equal(AzureProvisioningFailureDetails.LocationNotAvailableForResourceTypeErrorCode, resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.code").Value); 1297Assert.Equal("australiacentral", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.current.location").Value); 1298var supportedLocations = Assert.IsType<string[]>(resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.supported.locations").Value); 1762Assert.Equal("Azure deployment canceled", resourceEvent.Snapshot.State?.Text); 1801var property = Assert.Single(resourceEvent.Snapshot.Properties, p => p.Name == "azure.resource.group");
AzureEnvironmentResourceExtensionsTests.cs (110)
381Assert.Equal(KnownResourceStates.NotStarted, environmentEvent.Snapshot.State?.Text); 382Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Enabled, command.State)); 385Assert.Equal(KnownResourceStates.NotStarted, storageEvent.Snapshot.State?.Text); 386Assert.Empty(storageEvent.Snapshot.Urls); 387Assert.DoesNotContain(storageEvent.Snapshot.Properties, p => p.Name == "azure.subscription.id"); 388Assert.DoesNotContain(storageEvent.Snapshot.Properties, p => p.Name == CustomResourceKnownProperties.Source); 389Assert.Contains(storageEvent.Snapshot.Properties, p => p.Name == "custom.property"); 497Assert.Equal("Running", storageEvent.Snapshot.State?.Text); 570Assert.Equal(KnownResourceStates.Running, storageEvent.Snapshot.State?.Text); 709AssertCommandState(keyVaultEvent.Snapshot, AzureProvisioningController.ChangeResourceLocationCommandName, ResourceCommandState.Hidden); 710AssertCommandState(keyVaultEvent.Snapshot, AzureProvisioningController.GetAzureResourceCommandName, ResourceCommandState.Enabled); 711AssertCommandState(keyVaultEvent.Snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Hidden); 712AssertCommandState(keyVaultEvent.Snapshot, AzureProvisioningController.DeleteAzureResourceCommandName, ResourceCommandState.Enabled); 713AssertCommandState(keyVaultEvent.Snapshot, AzureProvisioningController.ForgetStateCommandName, ResourceCommandState.Enabled); 714AssertCommandState(keyVaultEvent.Snapshot, AzureProvisioningController.ReprovisionResourceCommandName, ResourceCommandState.Enabled); 744AssertCommandState(postgresEvent.Snapshot, AzureProvisioningController.ChangeResourceLocationCommandName, ResourceCommandState.Enabled); 1386Assert.Equal("Canceled", storageEvent.Snapshot.State?.Text); 1422AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.ChangeResourceLocationCommandName, ResourceCommandState.Disabled); 1423AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.GetAzureResourceCommandName, ResourceCommandState.Enabled); 1424AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Enabled); 1425AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.DeleteAzureResourceCommandName, ResourceCommandState.Disabled); 1426AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.ForgetStateCommandName, ResourceCommandState.Disabled); 1427AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.ReprovisionResourceCommandName, ResourceCommandState.Disabled); 1499AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Enabled); 1669var cancelCommand = Assert.Single(storageEvent.Snapshot.Commands, c => c.Name == AzureProvisioningController.CancelCommandName); 1724Assert.Equal(KnownResourceStates.Running, storageEvent.Snapshot.State?.Text); 1827Assert.Equal(KnownResourceStates.NotStarted, storageEvent.Snapshot.State?.Text); 1830Assert.Equal(KnownResourceStates.Running, storage2Event.Snapshot.State?.Text); 1909Assert.Equal(KnownResourceStates.NotStarted, keyVaultEvent.Snapshot.State?.Text); 1972Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Disabled, command.State)); 1975Assert.Equal("Deleting", storageEvent.Snapshot.State?.Text); 1976AssertAffectedResourceCommandsDuringOperation(storageEvent.Snapshot); 1979AssertUnaffectedResourceCommandsDuringOperation(storage2Event.Snapshot); 2063Assert.Equal("Canceled", storageEvent.Snapshot.State?.Text); 2136Assert.Equal(KnownResourceStates.NotStarted, storageEvent.Snapshot.State?.Text); 2137Assert.DoesNotContain(storageEvent.Snapshot.Properties, p => p.Name == CustomResourceKnownProperties.Source); 2138Assert.Contains(storageEvent.Snapshot.Properties, p => p.Name == "custom.property"); 2141Assert.Equal(KnownResourceStates.Running, storage2Event.Snapshot.State?.Text); 2142Assert.Contains(storage2Event.Snapshot.Properties, p => p.Name == CustomResourceKnownProperties.Source); 2198Assert.Equal("Running", storageEvent.Snapshot.State?.Text); 2201Assert.Equal(KnownResourceStates.Running, storage2Event.Snapshot.State?.Text); 2247Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Disabled, command.State)); 2250AssertAffectedResourceCommandsDuringOperation(storageEvent.Snapshot); 2253AssertUnaffectedResourceCommandsDuringOperation(storage2Event.Snapshot); 2261Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Enabled, command.State)); 2264AssertUnaffectedResourceCommandsDuringOperation(storageEvent.Snapshot); 2307Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Disabled, command.State)); 2310AssertAffectedResourceCommandsDuringOperation(storageEvent.Snapshot); 2319Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Enabled, command.State)); 2322AssertUnaffectedResourceCommandsDuringOperation(storageEvent.Snapshot); 2461AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Enabled); 2478Assert.Equal("Canceling", storageEvent.Snapshot.State?.Text); 2479AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Disabled); 2481Assert.Equal("Canceling", blobsEvent.Snapshot.State?.Text); 2490Assert.Equal("Canceled", storageEvent.Snapshot.State?.Text); 2491Assert.DoesNotContain(storageEvent.Snapshot.Properties, p => p.Name == AzureResourceProperties.OperationName); 2540AssertCommandState(runningStorage2Event.Snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Hidden); 2557storageEvent.Snapshot.State?.Text is "Canceling" or "Canceled", 2558$"Expected storage to be canceling or canceled, but it was '{storageEvent.Snapshot.State?.Text}'."); 2560Assert.Equal("Running", storage2Event.Snapshot.State?.Text); 2565Assert.Equal("Running", storage2Event.Snapshot.State?.Text); 2727Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Disabled, command.State)); 2730var storageSnapshot = storageEvent.Snapshot; 2739AssertUnaffectedResourceCommandsDuringOperation(storage2Event.Snapshot); 2740Assert.DoesNotContain(storage2Event.Snapshot.Properties, property => property.Name == AzureResourceProperties.OperationName); 3040Assert.Equal(KnownResourceStates.Running, storageEvent.Snapshot.State?.Text); 3485Assert.Equal(KnownResourceStates.Running, environmentEvent.Snapshot.State?.Text); 3486AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.subscription.id", "12345678-1234-1234-1234-123456789012", AzureProvisioningStrings.ContextPropertySubscriptionIdDisplayName); 3487AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.resource.group", "cli-rg-é", AzureProvisioningStrings.ContextPropertyResourceGroupDisplayName); 3488AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.location", "westus3", AzureProvisioningStrings.ContextPropertyLocationDisplayName); 3489AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.tenant.id", "87654321-4321-4321-4321-210987654321", AzureProvisioningStrings.ContextPropertyTenantIdDisplayName); 3538Assert.DoesNotContain(environmentEvent.Snapshot.Properties, p => p.Name == "azure.tenant.id"); 3936Assert.Equal("Running", keyVaultEvent.Snapshot.State?.Text); 4040Assert.Equal("Failed to Provision", keyVaultEvent.Snapshot.State?.Text); 4041Assert.Equal(AzureProvisioningFailureDetails.KeyVaultDeletedStateTombstoneNotFoundReason, keyVaultEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.code").Value?.ToString()); 4042var snapshotRecommendedActions = Assert.IsType<string[]>(keyVaultEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.recommendedActions").Value); 4247Assert.Equal("Failed to Provision", storageEvent.Snapshot.State?.Text); 4249storageEvent.Snapshot.Properties.Where(property => AzureProvisioningFailureDetails.IsFailureProperty(property.Name)), 4255Assert.Equal("Microsoft.ManagedIdentity", storageEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.provider").Value?.ToString()); 4256Assert.Equal("Microsoft.ManagedIdentity/userAssignedIdentities", storageEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.resource.type").Value?.ToString()); 4257Assert.Equal("LocationNotAvailableForResourceType", storageEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.code").Value?.ToString()); 4258Assert.Equal(400, storageEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.http.status").Value); 4259var snapshotRecommendedActions = Assert.IsType<string[]>(storageEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.recommendedActions").Value); 4333Assert.Equal(AzureProvisioningController.DriftedState, environmentEvent.Snapshot.State?.Text); 4334Assert.Equal(KnownResourceStateStyles.Error, environmentEvent.Snapshot.State?.Style); 4335AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.subscription.id", "12345678-1234-1234-1234-123456789012", AzureProvisioningStrings.ContextPropertySubscriptionIdDisplayName); 4336AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.resource.group", "test-rg", AzureProvisioningStrings.ContextPropertyResourceGroupDisplayName); 4337AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.location", "westus2", AzureProvisioningStrings.ContextPropertyLocationDisplayName); 4338AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.tenant.id", "87654321-4321-4321-4321-210987654321", AzureProvisioningStrings.ContextPropertyTenantIdDisplayName); 4339AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.tenant.domain", "testdomain.onmicrosoft.com", AzureProvisioningStrings.ContextPropertyTenantDomainDisplayName); 4342Assert.Equal(AzureProvisioningController.MissingInAzureState, resourceEvent.Snapshot.State?.Text); 4343Assert.Equal(KnownResourceStateStyles.Error, resourceEvent.Snapshot.State?.Style); 4386Assert.Equal(KnownResourceStates.Running, environmentEvent.Snapshot.State?.Text); 4389Assert.Equal(KnownResourceStates.Running, resourceEvent.Snapshot.State?.Text); 4445Assert.Equal(AzureProvisioningController.DriftedState, environmentEvent.Snapshot.State?.Text); 4448Assert.Equal(KnownResourceStates.Running, storageEvent.Snapshot.State?.Text); 4451Assert.Equal(AzureProvisioningController.MissingInAzureState, storage2Event.Snapshot.State?.Text); 4452Assert.Equal(KnownResourceStateStyles.Error, storage2Event.Snapshot.State?.Style); 4488Assert.Equal(KnownResourceStates.Running, environmentEvent.Snapshot.State?.Text); 4491Assert.Equal(KnownResourceStates.Running, resourceEvent.Snapshot.State?.Text); 4685Assert.Equal("Failed to Delete", environmentEvent.Snapshot.State?.Text); 4752Assert.Equal("Failed to Provision", storageEvent.Snapshot.State?.Text); 4755Assert.Equal("Failed to Provision", storageRolesEvent.Snapshot.State?.Text); 4823Assert.Equal(AzureProvisioningController.CancelingState, storageEvent.Snapshot.State?.Text); 4829Assert.Equal(AzureProvisioningStrings.ResourceStateCanceled, storageEvent.Snapshot.State?.Text); 4830Assert.Equal(KnownResourceStateStyles.Info, storageEvent.Snapshot.State?.Style); 4853Assert.Equal("Failed to Provision", environmentEvent.Snapshot.State?.Text); 4855var failedResourcesProperty = Assert.Single(environmentEvent.Snapshot.Properties, property => property.Name == "azure.provisioning.error.failed.resources"); 5159resourceEvent.Snapshot.State?.Text == expectedState) 5175? finalEvent.Snapshot.State?.Text
Aspire.Hosting.Blazor (6)
BlazorGatewayExtensions.cs (3)
432var gatewayState = resourceEvent.Snapshot.State; 445StartTimeStamp = resourceEvent.Snapshot.StartTimeStamp, 446StopTimeStamp = resourceEvent.Snapshot.StopTimeStamp,
BrowserDebuggerHelper.cs (3)
172? currentState.Snapshot.Version 302if (evt.Resource != debuggerResource || evt.Snapshot.Version <= minimumSnapshotVersion) 307var state = evt.Snapshot.State?.Text;
Aspire.Hosting.Blazor.Tests (1)
BrowserDebuggerHelperTests.cs (1)
147return currentState.Snapshot.Version;
Aspire.Hosting.Browsers (1)
BrowserLogsBuilderExtensions.cs (1)
188var parentState = resourceEvent.Snapshot.State?.Text;
Aspire.Hosting.Browsers.Tests (92)
BrowserLogsBuilderExtensionsTests.cs (91)
711HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.BrowserPropertyName, "chrome") && 712HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.UserDataModePropertyName, nameof(BrowserUserDataMode.Isolated)) && 713DoesNotHaveProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ProfilePropertyName)).DefaultTimeout(); 965resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running && 966HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.BrowserPropertyName, "msedge") && 967!resourceEvent.Snapshot.Properties.Any(property => property.Name == BrowserLogsBuilderExtensions.ProfilePropertyName)).DefaultTimeout(); 969var session = Assert.Single(GetBrowserSessions(runningEvent.Snapshot)); 1014resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running && 1015HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.BrowserExecutablePropertyName, "/fake/browser-1")).DefaultTimeout(); 1035resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running && 1036HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.BrowserPropertyName, tempBrowserPath) && 1037HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.BrowserExecutablePropertyName, tempBrowserPath) && 1038HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.BrowserHostOwnershipPropertyName, nameof(BrowserHostOwnership.Owned)) && 1039HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.LastErrorPropertyName, "InvalidOperationException: Launch failed.") && 1040HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionCountPropertyName, 1) && 1041resourceEvent.Snapshot.HealthReports.Any(report => 1046GetBrowserSessions(failedEvent.Snapshot), 1099resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running && 1100HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.BrowserExecutablePropertyName, "/fake/browser-1")).DefaultTimeout(); 1112resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running && 1113HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.BrowserPropertyName, "missing-browser") && 1114!resourceEvent.Snapshot.Properties.Any(property => property.Name == BrowserLogsBuilderExtensions.BrowserExecutablePropertyName) && 1115HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.BrowserHostOwnershipPropertyName, nameof(BrowserHostOwnership.Owned)) && 1116HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.LastErrorPropertyName, "InvalidOperationException: Launch failed.") && 1117HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionCountPropertyName, 1) && 1118resourceEvent.Snapshot.HealthReports.Any(report => 1123GetBrowserSessions(failedEvent.Snapshot), 1174resourceEvent.Snapshot.State?.Text == KnownResourceStates.FailedToStart && 1175HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionCountPropertyName, 0) && 1176HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionsPropertyName, "None") && 1177HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.LastErrorPropertyName, errorText) && 1178resourceEvent.Snapshot.HealthReports.Any(report => 1183Assert.Single(failedEvent.Snapshot.HealthReports); 1184Assert.Empty(GetBrowserSessions(failedEvent.Snapshot)); 1227resourceEvent.Snapshot.State?.Text == KnownResourceStates.FailedToStart && 1228HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.LastErrorPropertyName, "InvalidOperationException: Launch failed.")).DefaultTimeout(); 1236resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running && 1237HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionCountPropertyName, 1) && 1238DoesNotHaveProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.LastErrorPropertyName) && 1239!resourceEvent.Snapshot.HealthReports.Any(report => report.Name == BrowserLogsBuilderExtensions.LastErrorPropertyName)).DefaultTimeout(); 1242GetBrowserSessions(runningEvent.Snapshot), 1287resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running && 1288HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.BrowserHostOwnershipPropertyName, nameof(BrowserHostOwnership.Adopted)) && 1289HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionsPropertyName, "session-0001 (adopted browser)")).DefaultTimeout(); 1291var session = Assert.Single(GetBrowserSessions(runningEvent.Snapshot)); 1347resourceEvent => resourceEvent.Snapshot.Commands.Any(command => 1351Assert.Equal(ResourceCommandState.Disabled, initialEvent.Snapshot.Commands.Single(command => command.Name == BrowserLogsBuilderExtensions.OpenTrackedBrowserCommandName).State); 1363resourceEvent => resourceEvent.Snapshot.Commands.Any(command => 1367Assert.Equal(ResourceCommandState.Enabled, enabledEvent.Snapshot.Commands.Single(command => command.Name == BrowserLogsBuilderExtensions.OpenTrackedBrowserCommandName).State); 1411resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running && 1412HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionCountPropertyName, 1) && 1413HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionsPropertyName, "session-0001 (PID 1001)") && 1414HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.TotalSessionsLaunchedPropertyName, 1) && 1415HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.LastSessionPropertyName, "session-0001") && 1416HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.BrowserExecutablePropertyName, "/fake/browser-1") && 1417resourceEvent.Snapshot.HealthReports.Any(report => report.Name == "session-0001" && report.Status == HealthStatus.Healthy)).DefaultTimeout(); 1419Assert.Single(firstRunningEvent.Snapshot.HealthReports); 1421GetBrowserSessions(firstRunningEvent.Snapshot), 1447resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running && 1448HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionCountPropertyName, 2) && 1449HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionsPropertyName, "session-0001 (PID 1001), session-0002 (PID 1002)") && 1450HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.TotalSessionsLaunchedPropertyName, 2) && 1451HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.LastSessionPropertyName, "session-0002") && 1452HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.BrowserExecutablePropertyName, "/fake/browser-2") && 1453resourceEvent.Snapshot.HealthReports.Any(report => report.Name == "session-0001" && report.Status == HealthStatus.Healthy) && 1454resourceEvent.Snapshot.HealthReports.Any(report => report.Name == "session-0002" && report.Status == HealthStatus.Healthy)).DefaultTimeout(); 1456Assert.Equal(2, secondRunningEvent.Snapshot.HealthReports.Length); 1458GetBrowserSessions(secondRunningEvent.Snapshot), 1479resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running && 1480HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionCountPropertyName, 1) && 1481HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionsPropertyName, "session-0002 (PID 1002)") && 1482resourceEvent.Snapshot.HealthReports.Length == 1 && 1483resourceEvent.Snapshot.HealthReports[0].Name == "session-0002").DefaultTimeout(); 1485Assert.Equal("session-0002", firstCompletedEvent.Snapshot.HealthReports[0].Name); 1487GetBrowserSessions(firstCompletedEvent.Snapshot), 1495resourceEvent.Snapshot.State?.Text == KnownResourceStates.Finished && 1496HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionCountPropertyName, 0) && 1497HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionsPropertyName, "None") && 1498HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.TotalSessionsLaunchedPropertyName, 2) && 1499resourceEvent.Snapshot.HealthReports.IsEmpty).DefaultTimeout(); 1501Assert.Equal(KnownResourceStates.Finished, allCompletedEvent.Snapshot.State?.Text); 1502Assert.Empty(GetBrowserSessions(allCompletedEvent.Snapshot)); 1548resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running && 1549HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionCountPropertyName, 1) && 1550HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.LastErrorPropertyName, errorText) && 1551resourceEvent.Snapshot.HealthReports.Any(report => 1554resourceEvent.Snapshot.HealthReports.Any(report => 1564resourceEvent.Snapshot.State?.Text == KnownResourceStates.Exited && 1565HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionCountPropertyName, 0) && 1566HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.LastErrorPropertyName, errorText) && 1567resourceEvent.Snapshot.HealthReports.Any(report =>
src\Aspire.Hosting.Browsers\BrowserLogsBuilderExtensions.cs (1)
188var parentState = resourceEvent.Snapshot.State?.Text;
Aspire.Hosting.Containers.Tests (2)
DockerSocketBindMountTests.cs (2)
43e => KnownResourceStates.TerminalStates.Contains(e.Snapshot.State?.Text), 46Assert.Equal(KnownResourceStates.Exited, state.Snapshot.State);
Aspire.Hosting.DevTunnels.Tests (6)
DevTunnelResourceBuilderExtensionsTests.cs (6)
630e => e.Snapshot.State?.Text == KnownResourceStates.Running && 631e.Snapshot.Urls.Any(u => u.Url == tunnelUrl && !u.IsInactive) && 632e.Snapshot.Urls.Any(u => u.Url == inspectUrl && !u.IsInactive), 637Assert.Contains(resourceEvent.Snapshot.Urls, u => u.Url == tunnelUrl && !u.IsInactive); 638Assert.Contains(resourceEvent.Snapshot.Urls, u => u.Url == inspectUrl && !u.IsInactive); 667resourceEvent.Snapshot.Properties.Where(p => p.Name is
Aspire.Hosting.DotnetTool.Tests (2)
DotnetToolFunctionalTests.cs.cs (2)
29Assert.Equal(resourceState.Snapshot.ExitCode, 0); 51Assert.NotEqual(resourceState.Snapshot.ExitCode, 0);
Aspire.Hosting.EntityFrameworkCore (4)
EFCoreOperationExecutor.cs (4)
320r => r.Snapshot.State?.Text == KnownResourceStates.Finished || 321r.Snapshot.State?.Text == KnownResourceStates.Exited || 322r.Snapshot.State?.Text == KnownResourceStates.FailedToStart, 351var snapshot = resourceEvent.Snapshot;
Aspire.Hosting.Maui (2)
Lifecycle\MauiBuildQueueEventSubscriber.cs (2)
294var text = e.Snapshot.State?.Text; 402e => string.Equals(e.Snapshot.State?.Text, KnownResourceStates.FailedToStart, StringComparison.Ordinal),
Aspire.Hosting.Maui.Tests (3)
MauiBuildQueueTests.cs (3)
129if (evt.Resource.Name == env.MacCatalyst.Name && evt.Snapshot.State?.Text == "Queued") 163if (evt.Resource.Name == env.Android.Name && evt.Snapshot.State?.Text == "Building") 791if (evt.Resource.Name == resource.Name && evt.Snapshot.State?.Text == state)
Aspire.Hosting.MySql.Tests (2)
MySqlFunctionalTests.cs (2)
613return evt.Snapshot.Properties.FirstOrDefault(x => x.Name == "container.id")?.Value != null; 616return resourceEvent.Snapshot.Properties.FirstOrDefault(x => x.Name == "container.id")?.Value?.ToString();
Aspire.Hosting.PostgreSQL.Tests (2)
PostgresFunctionalTests.cs (2)
590return evt.Snapshot.Properties.FirstOrDefault(x => x.Name == "container.id")?.Value != null; 593return resourceEvent.Snapshot.Properties.FirstOrDefault(x => x.Name == "container.id")?.Value?.ToString();
Aspire.Hosting.Qdrant.Tests (1)
QdrantFunctionalTests.cs (1)
284await app.ResourceNotifications.WaitForResourceAsync(resource.Resource.Name, (re => re.Snapshot.HealthStatus == HealthStatus.Healthy), cts.Token);
Aspire.Hosting.Testing.Tests (2)
DashboardUrlTests.cs (2)
107resourceEvent => resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running, 135resourceEvent => resourceEvent.Snapshot.State?.Text == updatedState,
Aspire.Hosting.Tests (245)
Codespaces\CodespacesUrlRewriterTests.cs (3)
83var match = re.Snapshot.Urls.Length > 0 && re.Snapshot.Urls[0].Url.Contains("app.github.dev"); 89resourceEvent.Snapshot.Urls,
DistributedApplicationTests.cs (51)
209var resourceEvent = await rns.WaitForResourceAsync(dependentResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Waiting, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 213await rns.WaitForResourceAsync(dependentResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 217await rns.WaitForResourceAsync(dependentResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Finished, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 221await rns.WaitForResourceAsync(dependentResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Waiting, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 225await rns.WaitForResourceAsync(dependentResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 255var notStartedResourceEvent = await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.NotStarted, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 256var dependentResourceEvent = await rns.WaitForResourceAsync(dependentResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Waiting, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 259Assert.Contains("TestProject.ServiceA.csproj", notStartedResourceEvent.Snapshot.Properties.Single(p => p.Name == "project.path").Value?.ToString()); 260Assert.Contains("TestProject.ServiceB.csproj", dependentResourceEvent.Snapshot.Properties.Single(p => p.Name == "project.path").Value?.ToString()); 262Assert.Collection(notStartedResourceEvent.Snapshot.Urls, u => 268Assert.Collection(dependentResourceEvent.Snapshot.Urls, u => 277var runningResourceEvent = await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 278Assert.Collection(runningResourceEvent.Snapshot.Urls, u => 285var dependentResourceRunningEvent = await rns.WaitForResourceAsync(dependentResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 286Assert.Collection(dependentResourceRunningEvent.Snapshot.Urls, u => 294await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Finished, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 298await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 349await rns.WaitForResourceAsync(normalResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.DefaultOrchestratorTestTimeout); 352await rns.WaitForResourceAsync(explicitStartResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.NotStarted, token).DefaultTimeout(TestConstants.DefaultOrchestratorTestTimeout); 392var notStartedResourceEvent = await rns.WaitForResourceAsync(explicitStartResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.NotStarted, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 401await rns.WaitForResourceAsync(explicitStartResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.DefaultOrchestratorTestTimeout); 546e => e.Snapshot.State?.Text == KnownResourceStates.NotStarted, 551e => e.Snapshot.State?.Text == KnownResourceStates.Waiting, 555Assert.Collection(notStartedResourceEvent.Snapshot.Urls, u => 560Assert.Collection(dependentResourceEvent.Snapshot.Urls, u => 568Assert.Equal(RedisImageSource, notStartedResourceEvent.Snapshot.Properties.Single(p => p.Name == "container.image").Value?.ToString()); 569Assert.Contains("TestProject.ServiceB.csproj", dependentResourceEvent.Snapshot.Properties.Single(p => p.Name == "project.path").Value?.ToString()); 573var runningResourceEvent = await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 574Assert.Collection(runningResourceEvent.Snapshot.Urls, u => 580var dependentRunningResourceEvent = await rns.WaitForResourceAsync(dependentResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 581Assert.Collection(dependentRunningResourceEvent.Snapshot.Urls, u => 589await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Exited, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 593await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 635notStartedResourceEvent = await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.NotStarted, token).DefaultTimeout(TestConstants.ExtraLongTimeoutTimeSpan); 636dependentResourceEvent = await rns.WaitForResourceAsync(dependentResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Waiting, token).DefaultTimeout(TestConstants.ExtraLongTimeoutTimeSpan); 638Assert.Collection(notStartedResourceEvent.Snapshot.Urls, u => 643Assert.Collection(dependentResourceEvent.Snapshot.Urls, u => 651Assert.Equal(RedisImageSource, notStartedResourceEvent.Snapshot.Properties.Single(p => p.Name == "container.image").Value?.ToString()); 652Assert.Contains("TestProject.ServiceB.csproj", dependentResourceEvent.Snapshot.Properties.Single(p => p.Name == "project.path").Value?.ToString()); 658var runningResourceEvent = await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.ExtraLongTimeoutTimeSpan); 659Assert.Collection(runningResourceEvent.Snapshot.Urls, u => 665var dependentRunningResourceEvent = await rns.WaitForResourceAsync(dependentResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.ExtraLongTimeoutTimeSpan); 666Assert.Collection(dependentRunningResourceEvent.Snapshot.Urls, u => 674await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Exited, token).DefaultTimeout(TestConstants.ExtraLongTimeoutTimeSpan); 681await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.ExtraLongTimeoutTimeSpan); 1106var dependentRunningResourceEvent = await rns.WaitForResourceAsync(container.Resource.Name, e => e.Snapshot.State?.Text == KnownResourceStates.Running).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 2111var state = e.Snapshot.State?.Text; 2120var state = e.Snapshot.State?.Text; 2156e => e.Snapshot.State?.Text == KnownResourceStates.Running && 2161e => e.Snapshot.State?.Text == KnownResourceStates.Running && 2378return resourceEvent.Snapshot.Properties.FirstOrDefault(p => p.Name == propertyName)?.Value;
ExternalServiceTests.cs (6)
342e => e.Snapshot.State?.Text == KnownResourceStates.FailedToStart 346Assert.Equal(KnownResourceStates.FailedToStart, resourceEvent.Snapshot.State?.Text); 369e => e.Snapshot.State?.Text == KnownResourceStates.FailedToStart 373Assert.Equal(KnownResourceStates.FailedToStart, resourceEvent.Snapshot.State?.Text); 396e => e.Snapshot.State?.Text == KnownResourceStates.Running 400Assert.Equal(KnownResourceStates.Running, resourceEvent.Snapshot.State?.Text);
Health\ResourceHealthCheckServiceTests.cs (24)
38var startingEvent = await app.ResourceNotifications.WaitForResourceAsync("resource", e => e.Snapshot.State?.Text == KnownResourceStates.Starting).DefaultTimeout(); 39Assert.Null(startingEvent.Snapshot.HealthStatus); 47Assert.Equal(HealthStatus.Healthy, healthyEvent.Snapshot.HealthStatus); 78var startingEvent = await app.ResourceNotifications.WaitForResourceAsync("resource", e => e.Snapshot.State?.Text == KnownResourceStates.Starting).DefaultTimeout(); 79Assert.Null(startingEvent.Snapshot.HealthStatus); 86var runningEvent = await app.ResourceNotifications.WaitForResourceAsync("resource", e => e.Snapshot.State?.Text == KnownResourceStates.Running).DefaultTimeout(); 88Assert.Equal(HealthStatus.Unhealthy, runningEvent.Snapshot.HealthStatus); 121var startingEvent = await app.ResourceNotifications.WaitForResourceAsync("resource", e => e.Snapshot.State?.Text == KnownResourceStates.Starting).DefaultTimeout(); 122Assert.Null(startingEvent.Snapshot.HealthStatus); 130e => e.Snapshot.State?.Text == KnownResourceStates.Running && e.Snapshot.HealthReports.Single().Status == HealthStatus.Unhealthy).DefaultTimeout(); 132Assert.Equal(HealthStatus.Unhealthy, runningEvent.Snapshot.HealthStatus); 133Assert.Equal("Error calling HealthCheckService.", runningEvent.Snapshot.HealthReports.Single().Description); 587var startingEvent = await app.ResourceNotifications.WaitForResourceAsync("resource", e => e.Snapshot.State?.Text == KnownResourceStates.Starting).DefaultTimeout(); 588Assert.Null(startingEvent.Snapshot.HealthStatus); 596var runningEvent = await app.ResourceNotifications.WaitForResourceAsync("resource", e => e.Snapshot.State?.Text == KnownResourceStates.Running).DefaultTimeout(); 597Assert.Equal(HealthStatus.Unhealthy, runningEvent.Snapshot.HealthStatus); 604Assert.Equal(HealthStatus.Healthy, healthyEvent.Snapshot.HealthStatus); 633var startingEvent = await app.ResourceNotifications.WaitForResourceAsync("resource", e => e.Snapshot.State?.Text == KnownResourceStates.Starting).DefaultTimeout(); 634Assert.Null(startingEvent.Snapshot.HealthStatus); 641var runningEvent = await app.ResourceNotifications.WaitForResourceAsync("resource", e => e.Snapshot.State?.Text == KnownResourceStates.Running).DefaultTimeout(); 643Assert.Equal(HealthStatus.Unhealthy, runningEvent.Snapshot.HealthStatus); 649var unhealthyEvent = await app.ResourceNotifications.WaitForResourceAsync("resource", e => e.Snapshot.HealthStatus == HealthStatus.Unhealthy).DefaultTimeout(); 650Assert.Equal(HealthStatus.Unhealthy, unhealthyEvent.Snapshot.HealthStatus);
Lifecycle\TerminalHostFailureDiagnosticServiceTests.cs (2)
252if (evt.Resource == host && !evt.Snapshot.IsHidden) 265return evt.Snapshot;
Orchestrator\ApplicationOrchestratorTests.cs (37)
57childParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 105childParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 206childParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 210nestedChildParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 214child2ParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 275childParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 323projectBParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 473currentState.Snapshot.Properties, 519Assert.Equal(KnownResourceStates.FailedToStart, snapshotEvent.Snapshot.State?.Text); 520Assert.Equal(KnownResourceStateStyles.Error, snapshotEvent.Snapshot.State?.Style); 547Assert.Equal(KnownResourceStates.FailedToStart, snapshotEvent.Snapshot.State?.Text); 548Assert.Null(snapshotEvent.Snapshot.State?.Style); 571Assert.Equal(KnownResourceStates.Starting, snapshotEvent.Snapshot.State?.Text); 603Assert.Equal(KnownResourceStates.Waiting, waitingEvent.Snapshot.State?.Text); 644Assert.NotEqual(KnownResourceStates.Running, dependencyEvent.Snapshot.State?.Text); 692e => e.ResourceId == "waiter-abc123" && e.Snapshot.State?.Text == KnownResourceStates.Waiting, 750e => e.ResourceId == "waiter-abc123" && e.Snapshot.State?.Text == KnownResourceStates.Waiting, 754Assert.Equal(KnownResourceStates.NotStarted, siblingEvent.Snapshot.State?.Text); 801e => e.ResourceId == "waiter-abc123" && e.Snapshot.State?.Text == KnownResourceStates.Waiting, 855e => e.ResourceId == "waiter-abc123" && e.Snapshot.State?.Text == KnownResourceStates.Waiting, 863e => e.ResourceId == "waiter-def456" && e.Snapshot.State?.Text == KnownResourceStates.Waiting, 917Assert.NotEqual(KnownResourceStates.Running, blockerEvent.Snapshot.State?.Text); 966|| waiterEvent.Snapshot.State?.Text != KnownResourceStates.Waiting) 983Assert.NotEqual(KnownResourceStates.Running, blockerEvent.Snapshot.State?.Text); 1050re => re.Snapshot.State?.Text == KnownResourceStates.Waiting, 1053var waitingFor = waitingEvent.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.WaitingFor)?.Value; 1317var parentState = resourceNotificationService.TryGetCurrentState("parent-container-dcp", out var parentEvent) ? parentEvent.Snapshot.State?.Text : null; 1318var childContainerState = resourceNotificationService.TryGetCurrentState(childContainer.Resource.Name, out var childContainerEvent) ? childContainerEvent.Snapshot.State?.Text : null; 1319var customChildState = resourceNotificationService.TryGetCurrentState(customChild.Resource.Name, out var customChildEvent) ? customChildEvent.Snapshot.State?.Text : null; 1364var parentState = resourceNotificationService.TryGetCurrentState("parent-container-dcp", out var parentEvent) ? parentEvent.Snapshot.State?.Text : null; 1365var childProjectState = resourceNotificationService.TryGetCurrentState(childProject.Resource.Name, out var childProjectEvent) ? childProjectEvent.Snapshot.State?.Text : null; 1366var customChildState = resourceNotificationService.TryGetCurrentState(customChild.Resource.Name, out var customChildEvent) ? customChildEvent.Snapshot.State?.Text : null; 1413childParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 1417child2ParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 1470childParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 1474child2ParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 1524childProjectParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString();
Orchestrator\ParameterProcessorTests.cs (7)
91updates.Add((resourceEvent.Resource, resourceEvent.Snapshot)); 263Assert.Equal(KnownResourceStates.Running, updates.Current.Snapshot.State?.Text); 264AssertParameterValueProperty(updates.Current.Snapshot, "value1", isSensitive: false); 267Assert.Equal(KnownResourceStates.Running, updates.Current.Snapshot.State?.Text); 268AssertParameterValueProperty(updates.Current.Snapshot, "value2", isSensitive: false); 271Assert.Equal(KnownResourceStates.Running, updates.Current.Snapshot.State?.Text); 272AssertParameterValueProperty(updates.Current.Snapshot, "secretValue", isSensitive: true);
ResourceCommandServiceTests.cs (1)
1650await resourceNotificationService.WaitForResourceAsync(project.Resource.Name, e => KnownResourceStates.BuildableStates.Contains(e.Snapshot.State?.Text), cts.Token).DefaultTimeout(TimeSpan.FromMinutes(2));
ResourceNotificationTests.cs (74)
92Assert.Equal(expectedResourceType, resourceEvent.Snapshot.ResourceType); 133Assert.Equal("CustomResource", c.Snapshot.ResourceType); 134Assert.Equal("value", c.Snapshot.Properties.Single(p => p.Name == "A").Value); 135Assert.Null(c.Snapshot.HealthStatus); 141Assert.Equal("CustomResource", c.Snapshot.ResourceType); 142Assert.Equal("value", c.Snapshot.Properties.Single(p => p.Name == "B").Value); 143Assert.Null(c.Snapshot.HealthStatus); 160Assert.Equal(HealthStatus.Unhealthy, resourceEvent.Snapshot.HealthStatus); 162resourceEvent.Snapshot.HealthReports, 213Assert.Equal("CustomResource", c.Snapshot.ResourceType); 214Assert.Equal("value", c.Snapshot.Properties.Single(p => p.Name == "A").Value); 220Assert.Equal("CustomResource", c.Snapshot.ResourceType); 221Assert.Equal("value", c.Snapshot.Properties.Single(p => p.Name == "B").Value); 227Assert.Equal("CustomResource", c.Snapshot.ResourceType); 228Assert.Equal("value", c.Snapshot.Properties.Single(p => p.Name == "C").Value); 373re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 377Assert.Equal(KnownResourceStates.Waiting, waitingEvent.Snapshot.State?.Text); 386re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 400Assert.DoesNotContain(completedWaitingEvent.Snapshot.Properties, p => p.Name == KnownProperties.Resource.WaitingFor); 421re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 425Assert.Equal(KnownResourceStates.Waiting, waitingEvent.Snapshot.State?.Text); 439re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 458Assert.DoesNotContain(completedWaitingEvent.Snapshot.Properties, p => p.Name == KnownProperties.Resource.WaitingFor); 477re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 481Assert.Equal(KnownResourceStates.Waiting, waitingEvent.Snapshot.State?.Text); 491re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 506Assert.DoesNotContain(completedWaitingEvent.Snapshot.Properties, p => p.Name == KnownProperties.Resource.WaitingFor); 531re => re.Snapshot.State?.Text == KnownResourceStates.Waiting, 534Assert.Equal(KnownResourceStates.Waiting, waitingEvent.Snapshot.State?.Text); 577Assert.Equal(state, resourceEvent.Snapshot.State?.Text); 611re => re.ResourceId == "resource-abc123" && re.Snapshot.State?.Text == KnownResourceStates.Waiting, 615Assert.Equal(KnownResourceStates.NotStarted, notStartedEvent.Snapshot.State?.Text); 625Assert.Equal(KnownResourceStates.NotStarted, notStartedEvent.Snapshot.State?.Text); 655Assert.Equal(KnownResourceStates.NotStarted, notStartedEvent.Snapshot.State?.Text); 682re => re.Snapshot.State?.Text == KnownResourceStates.Waiting, 721re => re.ResourceId == "resource-abc123" && re.Snapshot.State?.Text == KnownResourceStates.Waiting, 753re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 766re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 780Assert.DoesNotContain(completedWaitingEvent.Snapshot.Properties, p => p.Name == KnownProperties.Resource.WaitingFor); 796Assert.Contains(waitingEvent.Snapshot.Properties, p => p.Name == KnownProperties.Resource.WaitingFor); 804Assert.DoesNotContain(runningEvent.Snapshot.Properties, p => p.Name == KnownProperties.Resource.WaitingFor); 857re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 1077Assert.Equal("ExistingIcon", firstEvent.Snapshot.IconName); 1078Assert.Equal(IconVariant.Filled, firstEvent.Snapshot.IconVariant); 1082Assert.Equal("ExistingIcon", secondEvent.Snapshot.IconName); 1083Assert.Equal(IconVariant.Filled, secondEvent.Snapshot.IconVariant); 1084Assert.Equal("Running", secondEvent.Snapshot.State?.Text); 1119Assert.Equal("LastIcon", value.Snapshot.IconName); 1120Assert.Equal(IconVariant.Regular, value.Snapshot.IconVariant); 1121Assert.Equal("Starting", value.Snapshot.State?.Text); 1155Assert.Equal("AnnotationIcon", value.Snapshot.IconName); 1156Assert.Equal(IconVariant.Regular, value.Snapshot.IconVariant); 1157Assert.Equal("Starting", value.Snapshot.State?.Text); 1299Assert.Equal(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Healthy, resourceEvent.Snapshot.HealthStatus); 1300Assert.NotNull(resourceEvent.Snapshot.ResourceReadyEvent); 1301Assert.True(resourceEvent.Snapshot.ResourceReadyEvent.EventTask.IsCompletedSuccessfully); 1367Assert.Equal(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Healthy, resourceEvent.Snapshot.HealthStatus); 1416return resourceEvent!.Snapshot.IsHidden; 1465Assert.Equal(initial.Snapshot.Version, unchanged.Snapshot.Version); 1470Assert.True(changed.Snapshot.Version > initial.Snapshot.Version, "A real change should publish a new version."); 1471Assert.Equal("SomeOtherState", changed.Snapshot.State?.Text); 1530Assert.Equal(initial.Snapshot.Version, unchanged.Snapshot.Version); 1543Assert.True(changed.Snapshot.Version > initial.Snapshot.Version, "A changed value inside a List<T> property should publish a new version."); 1562Assert.Equal(initial.Snapshot.Version, unchanged.Snapshot.Version); 1583changed.Snapshot.Version > initial.Snapshot.Version, 1615changed.Snapshot.Version > initial.Snapshot.Version, 1621var property = resourceEvent.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.WaitingFor);
WithHttpCommandTests.cs (12)
957e => e.Snapshot.State?.Text == KnownResourceStates.Starting).DefaultTimeout(); 959Assert.Equal(ResourceCommandState.Disabled, startingEvent.Snapshot.Commands.First(c => c.Name == "mycommand").State); 970e => e.Snapshot.State?.Text == KnownResourceStates.Running && 971e.Snapshot.Commands.First(c => c.Name == "mycommand").State == ResourceCommandState.Enabled).DefaultTimeout(); 973Assert.Equal(ResourceCommandState.Enabled, runningEvent.Snapshot.Commands.First(c => c.Name == "mycommand").State); 1013e => e.Snapshot.State?.Text == KnownResourceStates.Running && 1014e.Snapshot.Commands.First(c => c.Name == "mycommand").State == ResourceCommandState.Hidden).DefaultTimeout(); 1016Assert.Equal(ResourceCommandState.Hidden, runningEvent.Snapshot.Commands.First(c => c.Name == "mycommand").State); 1028e => e.Snapshot.Commands.First(c => c.Name == "mycommand").State == ResourceCommandState.Enabled).DefaultTimeout(); 1031Assert.Equal(ResourceCommandState.Enabled, enabledEvent.Snapshot.Commands.First(c => c.Name == "mycommand").State); 1069e => e.Snapshot.State?.Text == KnownResourceStates.Running && 1070e.Snapshot.Commands.FirstOrDefault(c => c.Name == commandName)?.State == ResourceCommandState.Enabled).DefaultTimeout();
WithUrlsTests.cs (28)
389e => e.Snapshot.Urls.Length == 1).DefaultTimeout(); 393Assert.Single(resourceEvent.Snapshot.Urls, s => s.Name == httpEndpoint.EndpointName && s.IsInactive && s.Url == "https://example.com"); 414e => e.Snapshot.Urls.Length == 3).DefaultTimeout(); 418Assert.Collection(resourceEvent.Snapshot.Urls, 447e => e.Snapshot.State == KnownResourceStates.Running 448&& e.Snapshot.Urls.Length == 2 449&& e.Snapshot.Urls.All(url => !url.IsInactive)).DefaultTimeout(); 453Assert.Equal(2, resourceEvent.Snapshot.Urls.Length); 454Assert.Collection(resourceEvent.Snapshot.Urls, 480if (notification.Resource == servicea.Resource && notification.Snapshot.Urls.Length > 0) 482urlSnapshots.Add(notification.Snapshot.Urls.ToArray()); 483testOutputHelper.WriteLine($"Captured snapshot #{urlSnapshots.Count}: State={notification.Snapshot.State}, URLs: {FormatUrls(notification.Snapshot.Urls)}"); 486if (notification.Snapshot.State == KnownResourceStates.Running && 487notification.Snapshot.Urls.All(u => !u.IsInactive)) 596if (notification.Resource == custom.Resource && notification.Snapshot.Urls.Length > 0) 598urlSnapshots.Add(notification.Snapshot.Urls.ToArray()); 599testOutputHelper.WriteLine($"Captured snapshot #{urlSnapshots.Count}: State={notification.Snapshot.State}, URLs: {FormatUrls(notification.Snapshot.Urls)}"); 602if (notification.Snapshot.State == KnownResourceStates.Running && 603notification.Snapshot.Urls.All(u => !u.IsInactive)) 673e => e.Snapshot.State == KnownResourceStates.Running && e.Snapshot.Urls.Length == 4).DefaultTimeout(); 677Assert.Collection(resourceEvent.Snapshot.Urls, 974e => e.Snapshot.State == KnownResourceStates.Running 975&& e.Snapshot.Urls.Length == resourceB.Resource.GetEndpoints().ToArray().Length + 1 976&& e.Snapshot.Urls.All(u => !u.IsInactive), 982var crossResourceUrl = resourceEvent.Snapshot.Urls.FirstOrDefault(u => u.DisplayProperties.DisplayName == "API Docs");
Aspire.Hosting.TestUtilities (3)
Utils\PersistentContainerTestHelpers.cs (3)
133(!includeUrls || evt.Snapshot.Urls.Length > 0); 143? string.Join(Environment.NewLine, resourceEvent.Snapshot.Urls 158resourceEvent.Snapshot.Properties.FirstOrDefault(x => x.Name == propertyName)?.Value;
Aspire.Playground.Tests (2)
Infrastructure\DistributedApplicationExtensions.cs (2)
107return Task.WhenAll(applicationModel.Resources.Select(r => app.ResourceNotifications.WaitForResourceAsync(r.Name, r => targetStates?.Contains(r.Snapshot.State?.Text, StringComparer.OrdinalIgnoreCase) is true || r.Snapshot.IsHidden, cancellationToken)));
Testing.Tests (2)
WaitFailures.cs (2)
156await app.ResourceNotifications.WaitForResourceAsync(nginx.Resource.Name, x => x.Snapshot.HealthReports.All(x => x.Status.HasValue), cts.Token); 176await app.ResourceNotifications.WaitForResourceAsync(nginx.Resource.Name, x => x.Snapshot.HealthStatus == HealthStatus.Healthy, cts.Token);