743 references to Snapshot
Aspire.Hosting (67)
ApplicationModel\CommandsConfigurationExtensions.cs (5)
218preRebuildStates[name] = evt.Snapshot.State?.Text; 286if (terminalEvent.Snapshot.State?.Text == KnownResourceStates.FailedToStart) 297exitCode = terminalEvent.Snapshot.ExitCode; 435var state = resourceEvent.Snapshot.State?.Text; 438(KnownResourceStates.TerminalStates.Contains(state) && resourceEvent.Snapshot.ExitCode is not null));
ApplicationModel\ResourceNotificationService.cs (19)
128re => re.Snapshot.State?.Text is { Length: > 0 } stateText && targetStates.Contains(stateText, StringComparers.ResourceState), 138var finalState = resourceEvent.Snapshot.State!.Text!; 162re => re.ResourceId == resourceId && re.Snapshot.HealthStatus == HealthStatus.Healthy, 172re => re.ResourceId == resourceId && re.Snapshot.ResourceReadyEvent is not null, 178await resourceEvent.Snapshot.ResourceReadyEvent!.EventTask.WaitAsync(cancellationToken).ConfigureAwait(false); 261re => ShouldYieldHealthyWait(waitBehavior, re.Snapshot), 275if (resourceEvent.Snapshot.HealthStatus != HealthStatus.Healthy) 284re => re.ResourceId == resourceEvent.ResourceId && re.Snapshot.ResourceReadyEvent is not null, 297var eventTask = resourceEvent.Snapshot.ResourceReadyEvent!.EventTask; 358re => re.ResourceId == resourceId && IsKnownTerminalState(re.Snapshot), 362var snapshot = resourceEvent.Snapshot; 422re => re.ResourceId == resourceId && IsContinuableState(waitBehavior, re.Snapshot), 426var snapshot = resourceEvent.Snapshot; 854if (versionsSeen.TryGetValue(item.ResourceId, out var maxVersionSeen) && item.Snapshot.Version <= maxVersionSeen) 1348if (TryGetCurrentState(resourceName, out var evt) && evt.Snapshot != null) 1350var snapshot = evt.Snapshot; 1390error.Append(CultureInfo.InvariantCulture, $" - {dependencyName}: State = {dependencyEvent.Snapshot.State?.Text ?? "(null)"}"); 1391error.Append(CultureInfo.InvariantCulture, $", Health = {dependencyEvent.Snapshot.HealthStatus?.ToString() ?? "(null)"}"); 1392if (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)
147var healthStatus = CustomResourceSnapshot.ComputeHealthStatus(resourceEvent.Snapshot.HealthReports, resourceEvent.Snapshot.State?.Text); 152Type = resourceEvent.Snapshot.ResourceType, 153State = resourceEvent.Snapshot.State?.Text ?? "Unknown",
Backchannel\AuxiliaryBackchannelRpcTarget.cs (18)
703re => ResourceNotificationService.ShouldYieldHealthyWait(WaitBehavior.StopOnResourceUnavailable, re.Snapshot), 707if (resourceEvent.Snapshot.HealthStatus != HealthStatus.Healthy) 715re => re.Snapshot.ResourceReadyEvent is not null, 719await resourceEvent.Snapshot.ResourceReadyEvent!.EventTask.WaitAsync(cancellationToken).ConfigureAwait(false); 724State = resourceEvent.Snapshot.State?.Text, 725HealthStatus = resourceEvent.Snapshot.HealthStatus?.ToString() 734re => re.Snapshot.State?.Text == KnownResourceStates.Running || 735KnownResourceStates.TerminalStates.Contains(re.Snapshot.State?.Text, StringComparers.ResourceState) || 736string.Equals(re.Snapshot.State?.Style, KnownResourceStateStyles.Error, StringComparisons.ResourceState) || 737re.Snapshot.ExitCode is not null, 741var state = resourceEvent.Snapshot.State?.Text; 748HealthStatus = resourceEvent.Snapshot.HealthStatus?.ToString(), 758re => KnownResourceStates.TerminalStates.Contains(re.Snapshot.State?.Text) || re.Snapshot.ExitCode is not null, 765State = resourceEvent.Snapshot.State?.Text, 766HealthStatus = resourceEvent.Snapshot.HealthStatus?.ToString() 1074var snapshot = resourceEvent.Snapshot; 1765return notificationService.TryGetCurrentState(resourceName, out var resourceEvent) && resourceEvent.Snapshot.IsHidden;
Dashboard\DashboardServiceData.cs (1)
101var 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)
848results.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)) 401if (currentEvent.Snapshot.Version <= previousEvent.Snapshot.Version) 405if (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 (1)
162if (e.Snapshot.State?.Text == KnownResourceStates.Waiting)
Aspire.Hosting.Azure (5)
AzureProvisioningController.cs (5)
2257environmentEvent.Snapshot.State?.Text != KnownResourceStates.Running) 3269return resourceEvent.Snapshot.Properties 3513return resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running; 3966string.Equals(currentEvent.Snapshot.State?.Text, state, StringComparison.Ordinal); 3972currentEvent.Snapshot.State is { Text: { } stateText } currentState &&
Aspire.Hosting.Azure.EntraId.Tests (19)
EntraIdInitializationTests.cs (19)
257Assert.Equal("Missing subscription configuration", resourceEvent.Snapshot.State?.Text); 281update => update.Snapshot.State?.Text == KnownResourceStates.FailedToStart, cts.Token); 291update => update.Snapshot.Properties.Any(property => property.Name == "entra.client.id" && Equals(property.Value, ClientId)), 294Assert.Equal(KnownResourceStates.Running, ready.Snapshot.State?.Text); 295Assert.Equal(new[] { "OpenID Config", "Azure Portal" }, ready.Snapshot.Urls.Select(url => url.Name)); 296Assert.Equal(TenantId, ready.Snapshot.Properties.Single(property => property.Name == "entra.tenant.id").Value); 326update => update.Snapshot.Properties.Any(property => property.Name == "entra.client.id"), cts.Token); 337update => update.Snapshot.State?.Text == KnownResourceStates.Running && 338update.Snapshot.Properties.Any(property => property.Name == "entra.client.id" && Equals(property.Value, updatedClient)), 341Assert.Equal(new[] { "docs", "OpenID Config", "Azure Portal" }, ready.Snapshot.Urls.Select(url => url.Name)); 343ready.Snapshot.Properties.Select(property => property.Name)); 344Assert.Equal(updatedTenant, ready.Snapshot.Properties.Single(property => property.Name == "entra.tenant.id").Value); 346ready.Snapshot.Urls.Single(url => url.Name == "OpenID Config").Url); 349ready.Snapshot.Urls.Single(url => url.Name == "Azure Portal").Url); 383update => update.Snapshot.Properties.Any(property => property.Name == "entra.client.id"), cts.Token); 504update => update.Snapshot.State?.Text == KnownResourceStates.FailedToStart || 505update.Snapshot.Properties.Any(property => property.Name == "entra.client.id"), 507return update.Snapshot; 518return resourceEvent.Snapshot;
Aspire.Hosting.Azure.Tests (141)
AzureBicepProvisionerTests.cs (29)
110var parentProperty = resourceEvent.Snapshot.Properties.FirstOrDefault(x => x.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 849AssertHighlightedContextProperty(resourceEvent.Snapshot.Properties, "azure.subscription.id", "12345678-1234-1234-1234-123456789012", AzureProvisioningStrings.ContextPropertySubscriptionIdDisplayName); 850AssertHighlightedContextProperty(resourceEvent.Snapshot.Properties, "azure.resource.group", "test-rg", AzureProvisioningStrings.ContextPropertyResourceGroupDisplayName); 851AssertHighlightedContextProperty(resourceEvent.Snapshot.Properties, "azure.tenant.id", "87654321-4321-4321-4321-210987654321", AzureProvisioningStrings.ContextPropertyTenantIdDisplayName); 852AssertHighlightedContextProperty(resourceEvent.Snapshot.Properties, "azure.tenant.domain", "testdomain.onmicrosoft.com", AzureProvisioningStrings.ContextPropertyTenantDomainDisplayName); 853AssertHighlightedContextProperty(resourceEvent.Snapshot.Properties, "azure.location", "westus3", AzureProvisioningStrings.ContextPropertyLocationDisplayName); 854Assert.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()); 883Assert.Equal("87654321-4321-4321-4321-210987654321", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.tenant.id").Value?.ToString()); 884Assert.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()); 921Assert.Equal("87654321-4321-4321-4321-210987654321", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.tenant.id").Value?.ToString()); 922Assert.Equal(expectedDeploymentId, resourceEvent.Snapshot.Properties.Single(p => p.Name == CustomResourceKnownProperties.Source).Value?.ToString()); 923Assert.Equal(BicepProvisioner.GetDeploymentUrl(new ResourceIdentifier(expectedDeploymentId)), resourceEvent.Snapshot.Urls.Single(u => u.Name == "deployment").Url); 1035Assert.Equal("12345678-1234-1234-1234-123456789012", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.subscription.id").Value?.ToString()); 1036Assert.Equal("test-rg", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.resource.group").Value?.ToString()); 1037Assert.Equal("87654321-4321-4321-4321-210987654321", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.tenant.id").Value?.ToString()); 1038Assert.Equal("microsoft.onmicrosoft.com", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.tenant.domain").Value?.ToString()); 1039Assert.Equal("westus2", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.location").Value?.ToString()); 1040Assert.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()); 1086Assert.Equal("scoped-rg", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.resource.group").Value?.ToString()); 1277Assert.Equal("Azure deployment failed", resourceEvent.Snapshot.State?.Text); 1279resourceEvent.Snapshot.Properties, 1323resourceEvent.Snapshot.Properties.Where(static property => 1392Assert.Equal("Azure deployment failed", resourceEvent.Snapshot.State?.Text); 1393Assert.DoesNotContain(resourceEvent.Snapshot.Properties, p => p.Name.StartsWith("azure.deployment.operations.", StringComparison.Ordinal)); 1394Assert.Equal(AzureProvisioningFailureDetails.LocationNotAvailableForResourceTypeErrorCode, resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.code").Value); 1395Assert.Equal("australiacentral", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.current.location").Value); 1396var supportedLocations = Assert.IsType<string[]>(resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.supported.locations").Value); 1860Assert.Equal("Azure deployment canceled", resourceEvent.Snapshot.State?.Text); 1899var property = Assert.Single(resourceEvent.Snapshot.Properties, p => p.Name == "azure.resource.group");
AzureEnvironmentResourceExtensionsTests.cs (112)
121Assert.Equal(KnownResourceStates.Running, directorySnapshot.Snapshot.State?.Text); 122Assert.Single(directorySnapshot.Snapshot.Urls); 677Assert.Equal(KnownResourceStates.NotStarted, environmentEvent.Snapshot.State?.Text); 678Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Enabled, command.State)); 681Assert.Equal(KnownResourceStates.NotStarted, storageEvent.Snapshot.State?.Text); 682Assert.Empty(storageEvent.Snapshot.Urls); 683Assert.DoesNotContain(storageEvent.Snapshot.Properties, p => p.Name == "azure.subscription.id"); 684Assert.DoesNotContain(storageEvent.Snapshot.Properties, p => p.Name == CustomResourceKnownProperties.Source); 685Assert.Contains(storageEvent.Snapshot.Properties, p => p.Name == "custom.property"); 793Assert.Equal("Running", storageEvent.Snapshot.State?.Text); 866Assert.Equal(KnownResourceStates.Running, storageEvent.Snapshot.State?.Text); 1027AssertCommandState(keyVaultEvent.Snapshot, AzureProvisioningController.ChangeResourceLocationCommandName, ResourceCommandState.Hidden); 1028AssertCommandState(keyVaultEvent.Snapshot, AzureProvisioningController.GetAzureResourceCommandName, ResourceCommandState.Enabled); 1029AssertCommandState(keyVaultEvent.Snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Hidden); 1030AssertCommandState(keyVaultEvent.Snapshot, AzureProvisioningController.DeleteAzureResourceCommandName, ResourceCommandState.Enabled); 1031AssertCommandState(keyVaultEvent.Snapshot, AzureProvisioningController.ForgetStateCommandName, ResourceCommandState.Enabled); 1032AssertCommandState(keyVaultEvent.Snapshot, AzureProvisioningController.ReprovisionResourceCommandName, ResourceCommandState.Enabled); 1062AssertCommandState(postgresEvent.Snapshot, AzureProvisioningController.ChangeResourceLocationCommandName, ResourceCommandState.Enabled); 1704Assert.Equal("Canceled", storageEvent.Snapshot.State?.Text); 1740AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.ChangeResourceLocationCommandName, ResourceCommandState.Disabled); 1741AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.GetAzureResourceCommandName, ResourceCommandState.Enabled); 1742AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Enabled); 1743AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.DeleteAzureResourceCommandName, ResourceCommandState.Disabled); 1744AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.ForgetStateCommandName, ResourceCommandState.Disabled); 1745AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.ReprovisionResourceCommandName, ResourceCommandState.Disabled); 1817AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Enabled); 1987var cancelCommand = Assert.Single(storageEvent.Snapshot.Commands, c => c.Name == AzureProvisioningController.CancelCommandName); 2042Assert.Equal(KnownResourceStates.Running, storageEvent.Snapshot.State?.Text); 2145Assert.Equal(KnownResourceStates.NotStarted, storageEvent.Snapshot.State?.Text); 2148Assert.Equal(KnownResourceStates.Running, storage2Event.Snapshot.State?.Text); 2227Assert.Equal(KnownResourceStates.NotStarted, keyVaultEvent.Snapshot.State?.Text); 2290Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Disabled, command.State)); 2293Assert.Equal("Deleting", storageEvent.Snapshot.State?.Text); 2294AssertAffectedResourceCommandsDuringOperation(storageEvent.Snapshot); 2297AssertUnaffectedResourceCommandsDuringOperation(storage2Event.Snapshot); 2381Assert.Equal("Canceled", storageEvent.Snapshot.State?.Text); 2454Assert.Equal(KnownResourceStates.NotStarted, storageEvent.Snapshot.State?.Text); 2455Assert.DoesNotContain(storageEvent.Snapshot.Properties, p => p.Name == CustomResourceKnownProperties.Source); 2456Assert.Contains(storageEvent.Snapshot.Properties, p => p.Name == "custom.property"); 2459Assert.Equal(KnownResourceStates.Running, storage2Event.Snapshot.State?.Text); 2460Assert.Contains(storage2Event.Snapshot.Properties, p => p.Name == CustomResourceKnownProperties.Source); 2516Assert.Equal("Running", storageEvent.Snapshot.State?.Text); 2519Assert.Equal(KnownResourceStates.Running, storage2Event.Snapshot.State?.Text); 2565Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Disabled, command.State)); 2568AssertAffectedResourceCommandsDuringOperation(storageEvent.Snapshot); 2571AssertUnaffectedResourceCommandsDuringOperation(storage2Event.Snapshot); 2579Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Enabled, command.State)); 2582AssertUnaffectedResourceCommandsDuringOperation(storageEvent.Snapshot); 2625Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Disabled, command.State)); 2628AssertAffectedResourceCommandsDuringOperation(storageEvent.Snapshot); 2637Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Enabled, command.State)); 2640AssertUnaffectedResourceCommandsDuringOperation(storageEvent.Snapshot); 2779AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Enabled); 2796Assert.Equal("Canceling", storageEvent.Snapshot.State?.Text); 2797AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Disabled); 2799Assert.Equal("Canceling", blobsEvent.Snapshot.State?.Text); 2808Assert.Equal("Canceled", storageEvent.Snapshot.State?.Text); 2809Assert.DoesNotContain(storageEvent.Snapshot.Properties, p => p.Name == AzureResourceProperties.OperationName); 2858AssertCommandState(runningStorage2Event.Snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Hidden); 2875storageEvent.Snapshot.State?.Text is "Canceling" or "Canceled", 2876$"Expected storage to be canceling or canceled, but it was '{storageEvent.Snapshot.State?.Text}'."); 2878Assert.Equal("Running", storage2Event.Snapshot.State?.Text); 2883Assert.Equal("Running", storage2Event.Snapshot.State?.Text); 3045Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Disabled, command.State)); 3048var storageSnapshot = storageEvent.Snapshot; 3057AssertUnaffectedResourceCommandsDuringOperation(storage2Event.Snapshot); 3058Assert.DoesNotContain(storage2Event.Snapshot.Properties, property => property.Name == AzureResourceProperties.OperationName); 3358Assert.Equal(KnownResourceStates.Running, storageEvent.Snapshot.State?.Text); 3803Assert.Equal(KnownResourceStates.Running, environmentEvent.Snapshot.State?.Text); 3804AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.subscription.id", "12345678-1234-1234-1234-123456789012", AzureProvisioningStrings.ContextPropertySubscriptionIdDisplayName); 3805AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.resource.group", "cli-rg-é", AzureProvisioningStrings.ContextPropertyResourceGroupDisplayName); 3806AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.location", "westus3", AzureProvisioningStrings.ContextPropertyLocationDisplayName); 3807AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.tenant.id", "87654321-4321-4321-4321-210987654321", AzureProvisioningStrings.ContextPropertyTenantIdDisplayName); 3856Assert.DoesNotContain(environmentEvent.Snapshot.Properties, p => p.Name == "azure.tenant.id"); 4254Assert.Equal("Running", keyVaultEvent.Snapshot.State?.Text); 4358Assert.Equal("Failed to Provision", keyVaultEvent.Snapshot.State?.Text); 4359Assert.Equal(AzureProvisioningFailureDetails.KeyVaultDeletedStateTombstoneNotFoundReason, keyVaultEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.code").Value?.ToString()); 4360var snapshotRecommendedActions = Assert.IsType<string[]>(keyVaultEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.recommendedActions").Value); 4565Assert.Equal("Failed to Provision", storageEvent.Snapshot.State?.Text); 4567storageEvent.Snapshot.Properties.Where(property => AzureProvisioningFailureDetails.IsFailureProperty(property.Name)), 4573Assert.Equal("Microsoft.ManagedIdentity", storageEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.provider").Value?.ToString()); 4574Assert.Equal("Microsoft.ManagedIdentity/userAssignedIdentities", storageEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.resource.type").Value?.ToString()); 4575Assert.Equal("LocationNotAvailableForResourceType", storageEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.code").Value?.ToString()); 4576Assert.Equal(400, storageEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.http.status").Value); 4577var snapshotRecommendedActions = Assert.IsType<string[]>(storageEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.recommendedActions").Value); 4651Assert.Equal(AzureProvisioningController.DriftedState, environmentEvent.Snapshot.State?.Text); 4652Assert.Equal(KnownResourceStateStyles.Error, environmentEvent.Snapshot.State?.Style); 4653AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.subscription.id", "12345678-1234-1234-1234-123456789012", AzureProvisioningStrings.ContextPropertySubscriptionIdDisplayName); 4654AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.resource.group", "test-rg", AzureProvisioningStrings.ContextPropertyResourceGroupDisplayName); 4655AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.location", "westus2", AzureProvisioningStrings.ContextPropertyLocationDisplayName); 4656AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.tenant.id", "87654321-4321-4321-4321-210987654321", AzureProvisioningStrings.ContextPropertyTenantIdDisplayName); 4657AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.tenant.domain", "testdomain.onmicrosoft.com", AzureProvisioningStrings.ContextPropertyTenantDomainDisplayName); 4660Assert.Equal(AzureProvisioningController.MissingInAzureState, resourceEvent.Snapshot.State?.Text); 4661Assert.Equal(KnownResourceStateStyles.Error, resourceEvent.Snapshot.State?.Style); 4704Assert.Equal(KnownResourceStates.Running, environmentEvent.Snapshot.State?.Text); 4707Assert.Equal(KnownResourceStates.Running, resourceEvent.Snapshot.State?.Text); 4763Assert.Equal(AzureProvisioningController.DriftedState, environmentEvent.Snapshot.State?.Text); 4766Assert.Equal(KnownResourceStates.Running, storageEvent.Snapshot.State?.Text); 4769Assert.Equal(AzureProvisioningController.MissingInAzureState, storage2Event.Snapshot.State?.Text); 4770Assert.Equal(KnownResourceStateStyles.Error, storage2Event.Snapshot.State?.Style); 4806Assert.Equal(KnownResourceStates.Running, environmentEvent.Snapshot.State?.Text); 4809Assert.Equal(KnownResourceStates.Running, resourceEvent.Snapshot.State?.Text); 5003Assert.Equal("Failed to Delete", environmentEvent.Snapshot.State?.Text); 5070Assert.Equal("Failed to Provision", storageEvent.Snapshot.State?.Text); 5073Assert.Equal("Failed to Provision", storageRolesEvent.Snapshot.State?.Text); 5141Assert.Equal(AzureProvisioningController.CancelingState, storageEvent.Snapshot.State?.Text); 5147Assert.Equal(AzureProvisioningStrings.ResourceStateCanceled, storageEvent.Snapshot.State?.Text); 5148Assert.Equal(KnownResourceStateStyles.Info, storageEvent.Snapshot.State?.Style); 5171Assert.Equal("Failed to Provision", environmentEvent.Snapshot.State?.Text); 5173var failedResourcesProperty = Assert.Single(environmentEvent.Snapshot.Properties, property => property.Name == "azure.provisioning.error.failed.resources"); 5489resourceEvent.Snapshot.State?.Text == expectedState) 5505? finalEvent.Snapshot.State?.Text
Aspire.Hosting.Blazor (6)
BlazorGatewayExtensions.cs (3)
520var gatewayState = resourceEvent.Snapshot.State; 533StartTimeStamp = resourceEvent.Snapshot.StartTimeStamp, 534StopTimeStamp = 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)
710HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.BrowserPropertyName, "chrome") && 711HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.UserDataModePropertyName, nameof(BrowserUserDataMode.Isolated)) && 712DoesNotHaveProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ProfilePropertyName)).DefaultTimeout(); 964resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running && 965HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.BrowserPropertyName, "msedge") && 966!resourceEvent.Snapshot.Properties.Any(property => property.Name == BrowserLogsBuilderExtensions.ProfilePropertyName)).DefaultTimeout(); 968var session = Assert.Single(GetBrowserSessions(runningEvent.Snapshot)); 1013resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running && 1014HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.BrowserExecutablePropertyName, "/fake/browser-1")).DefaultTimeout(); 1034resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running && 1035HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.BrowserPropertyName, tempBrowserPath) && 1036HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.BrowserExecutablePropertyName, tempBrowserPath) && 1037HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.BrowserHostOwnershipPropertyName, nameof(BrowserHostOwnership.Owned)) && 1038HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.LastErrorPropertyName, "InvalidOperationException: Launch failed.") && 1039HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionCountPropertyName, 1) && 1040resourceEvent.Snapshot.HealthReports.Any(report => 1045GetBrowserSessions(failedEvent.Snapshot), 1098resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running && 1099HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.BrowserExecutablePropertyName, "/fake/browser-1")).DefaultTimeout(); 1111resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running && 1112HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.BrowserPropertyName, "missing-browser") && 1113!resourceEvent.Snapshot.Properties.Any(property => property.Name == BrowserLogsBuilderExtensions.BrowserExecutablePropertyName) && 1114HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.BrowserHostOwnershipPropertyName, nameof(BrowserHostOwnership.Owned)) && 1115HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.LastErrorPropertyName, "InvalidOperationException: Launch failed.") && 1116HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionCountPropertyName, 1) && 1117resourceEvent.Snapshot.HealthReports.Any(report => 1122GetBrowserSessions(failedEvent.Snapshot), 1173resourceEvent.Snapshot.State?.Text == KnownResourceStates.FailedToStart && 1174HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionCountPropertyName, 0) && 1175HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionsPropertyName, "None") && 1176HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.LastErrorPropertyName, errorText) && 1177resourceEvent.Snapshot.HealthReports.Any(report => 1182Assert.Single(failedEvent.Snapshot.HealthReports); 1183Assert.Empty(GetBrowserSessions(failedEvent.Snapshot)); 1226resourceEvent.Snapshot.State?.Text == KnownResourceStates.FailedToStart && 1227HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.LastErrorPropertyName, "InvalidOperationException: Launch failed.")).DefaultTimeout(); 1235resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running && 1236HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionCountPropertyName, 1) && 1237DoesNotHaveProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.LastErrorPropertyName) && 1238!resourceEvent.Snapshot.HealthReports.Any(report => report.Name == BrowserLogsBuilderExtensions.LastErrorPropertyName)).DefaultTimeout(); 1241GetBrowserSessions(runningEvent.Snapshot), 1286resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running && 1287HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.BrowserHostOwnershipPropertyName, nameof(BrowserHostOwnership.Adopted)) && 1288HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionsPropertyName, "session-0001 (adopted browser)")).DefaultTimeout(); 1290var session = Assert.Single(GetBrowserSessions(runningEvent.Snapshot)); 1346resourceEvent => resourceEvent.Snapshot.Commands.Any(command => 1350Assert.Equal(ResourceCommandState.Disabled, initialEvent.Snapshot.Commands.Single(command => command.Name == BrowserLogsBuilderExtensions.OpenTrackedBrowserCommandName).State); 1362resourceEvent => resourceEvent.Snapshot.Commands.Any(command => 1366Assert.Equal(ResourceCommandState.Enabled, enabledEvent.Snapshot.Commands.Single(command => command.Name == BrowserLogsBuilderExtensions.OpenTrackedBrowserCommandName).State); 1410resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running && 1411HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionCountPropertyName, 1) && 1412HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionsPropertyName, "session-0001 (PID 1001)") && 1413HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.TotalSessionsLaunchedPropertyName, 1) && 1414HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.LastSessionPropertyName, "session-0001") && 1415HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.BrowserExecutablePropertyName, "/fake/browser-1") && 1416resourceEvent.Snapshot.HealthReports.Any(report => report.Name == "session-0001" && report.Status == HealthStatus.Healthy)).DefaultTimeout(); 1418Assert.Single(firstRunningEvent.Snapshot.HealthReports); 1420GetBrowserSessions(firstRunningEvent.Snapshot), 1446resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running && 1447HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionCountPropertyName, 2) && 1448HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionsPropertyName, "session-0001 (PID 1001), session-0002 (PID 1002)") && 1449HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.TotalSessionsLaunchedPropertyName, 2) && 1450HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.LastSessionPropertyName, "session-0002") && 1451HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.BrowserExecutablePropertyName, "/fake/browser-2") && 1452resourceEvent.Snapshot.HealthReports.Any(report => report.Name == "session-0001" && report.Status == HealthStatus.Healthy) && 1453resourceEvent.Snapshot.HealthReports.Any(report => report.Name == "session-0002" && report.Status == HealthStatus.Healthy)).DefaultTimeout(); 1455Assert.Equal(2, secondRunningEvent.Snapshot.HealthReports.Length); 1457GetBrowserSessions(secondRunningEvent.Snapshot), 1478resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running && 1479HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionCountPropertyName, 1) && 1480HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionsPropertyName, "session-0002 (PID 1002)") && 1481resourceEvent.Snapshot.HealthReports.Length == 1 && 1482resourceEvent.Snapshot.HealthReports[0].Name == "session-0002").DefaultTimeout(); 1484Assert.Equal("session-0002", firstCompletedEvent.Snapshot.HealthReports[0].Name); 1486GetBrowserSessions(firstCompletedEvent.Snapshot), 1494resourceEvent.Snapshot.State?.Text == KnownResourceStates.Finished && 1495HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionCountPropertyName, 0) && 1496HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionsPropertyName, "None") && 1497HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.TotalSessionsLaunchedPropertyName, 2) && 1498resourceEvent.Snapshot.HealthReports.IsEmpty).DefaultTimeout(); 1500Assert.Equal(KnownResourceStates.Finished, allCompletedEvent.Snapshot.State?.Text); 1501Assert.Empty(GetBrowserSessions(allCompletedEvent.Snapshot)); 1547resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running && 1548HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionCountPropertyName, 1) && 1549HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.LastErrorPropertyName, errorText) && 1550resourceEvent.Snapshot.HealthReports.Any(report => 1553resourceEvent.Snapshot.HealthReports.Any(report => 1563resourceEvent.Snapshot.State?.Text == KnownResourceStates.Exited && 1564HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.ActiveSessionCountPropertyName, 0) && 1565HasProperty(resourceEvent.Snapshot, BrowserLogsBuilderExtensions.LastErrorPropertyName, errorText) && 1566resourceEvent.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 (7)
DevTunnelMonitor.cs (3)
437&& KnownResourceStates.TerminalStates.Contains(update.Snapshot.State?.Text)) 480&& current.Snapshot.StartTimeStamp is { } startedAt 702|| !KnownResourceStates.TerminalStates.Contains(current.Snapshot.State?.Text));
DevTunnelResourceBuilderExtensions.cs (4)
741&& previous.Snapshot.State?.Text == KnownResourceStates.Running 742&& previous.Snapshot.HealthStatus == HealthStatus.Healthy; 803? current.Snapshot.Properties.FirstOrDefault(p => p.Name == "Anonymous access")?.Value as string 824&& KnownResourceStates.TerminalStates.Contains(current.Snapshot.State?.Text))
Aspire.Hosting.DevTunnels.Tests (17)
DevTunnelResourceBuilderExtensionsTests.cs (14)
325e => e.Snapshot.Properties.Any(p => p.Name == "Anonymous access")).DefaultTimeout(); 389e => e.Snapshot.Properties.Any(p => p.Name == "Anonymous access")).DefaultTimeout(); 821e => e.Snapshot.Urls.Any(u => u.Url == inspectUrl) 822&& e.Snapshot.Urls.Any(u => u.Url == "https://example.com/diagnostics") 823&& e.Snapshot.Urls.All(u => u.IsInactive == expectedInactive), cts.Token); 824Assert.Equal(restartBeforeUrlCallbackCompletes ? KnownResourceStates.Running : KnownResourceStates.Finished, completed.Snapshot.State?.Text); 825Assert.True(completed.Snapshot.Urls.Length >= 3); 832Assert.NotNull(completed.Snapshot.StopTimeStamp); 844e => e.Snapshot.State?.Text == KnownResourceStates.Running && 845e.Snapshot.Urls.Any(u => u.Url == tunnelUrl && !u.IsInactive) && 846e.Snapshot.Urls.Any(u => u.Url == inspectUrl && !u.IsInactive), 852Assert.Contains(resourceEvent.Snapshot.Urls, u => u.Url == tunnelUrl && !u.IsInactive); 853Assert.Contains(resourceEvent.Snapshot.Urls, u => u.Url == inspectUrl && !u.IsInactive); 892resourceEvent.Snapshot.Properties.Where(p => p.Name is
TestDevTunnelMonitor.cs (3)
88e => e.Snapshot.State?.Text == KnownResourceStates.Running && e.Snapshot.HealthStatus == Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Healthy).DefaultTimeout(); 94return current.Snapshot;
Aspire.Hosting.Dotnet (12)
DotnetProjectBuildCoordinator.cs (12)
189resourceEvent => IsSettledBuildSnapshot(resourceEvent.Snapshot), 192if (buildEvent.Snapshot.State?.Text == KnownResourceStates.FailedToStart || 193buildEvent.Snapshot.ExitCode is not 0) 195var exitCode = buildEvent.Snapshot.ExitCode?.ToString(CultureInfo.InvariantCulture) ?? "unavailable"; 305rebuildEvent.Snapshot.State?.Text is { } state && 927? resourceEvent.Snapshot 1007? resourceEvent.Snapshot 1229!ReferenceEquals(resourceEvent.Snapshot, initialSnapshot) && 1230IsSettledBuildSnapshot(resourceEvent.Snapshot), 1261!ReferenceEquals(resourceEvent.Snapshot, initialSnapshot) && 1262(resourceEvent.Snapshot.State?.Text == KnownResourceStates.FailedToStart || 1263KnownResourceStates.TerminalStates.Contains(resourceEvent.Snapshot.State?.Text)),
Aspire.Hosting.Dotnet.Tests (27)
DotnetProjectBuildCoordinatorTests.cs (27)
589resourceEvent.Snapshot.State?.Text == KnownResourceStates.Finished && 590resourceEvent.Snapshot.ExitCode is not null, 595resourceEvent.Snapshot.State?.Text == KnownResourceStates.Finished && 596resourceEvent.Snapshot.ExitCode is not null, 598Assert.All(completionEvents, resourceEvent => Assert.Equal(0, resourceEvent.Snapshot.ExitCode)); 2824resourceEvent => resourceEvent.ResourceId == name && resourceEvent.Snapshot.State?.Text == KnownResourceStates.Finished, 2828var properties = completedResource.Snapshot.Properties; 2829Assert.Equal("Project", completedResource.Snapshot.ResourceType); 2880resourceEvent => resourceEvent.ResourceId == name && resourceEvent.Snapshot.State?.Text == KnownResourceStates.FailedToStart, 2927resourceEvent => DotnetProjectBuildCoordinator.IsSettledBuildSnapshot(resourceEvent.Snapshot), 2933Assert.Equal(0, secondBuildEvent.Snapshot.ExitCode); 2976resourceEvent => DotnetProjectBuildCoordinator.IsSettledBuildSnapshot(resourceEvent.Snapshot), 2980resourceEvent => DotnetProjectBuildCoordinator.IsSettledBuildSnapshot(resourceEvent.Snapshot), 2987Assert.Equal(KnownResourceStates.Finished, firstBuildEvent.Snapshot.State?.Text); 2988Assert.NotEqual(0, Assert.IsType<int>(firstBuildEvent.Snapshot.ExitCode)); 2989Assert.Equal(KnownResourceStates.FailedToStart, secondBuildEvent.Snapshot.State?.Text); 3268Assert.Equal(KnownResourceStates.NotStarted, projectEvent.Snapshot.State?.Text); 3686KnownResourceStates.TerminalStates.Contains(resourceEvent.Snapshot.State?.Text) && 3687resourceEvent.Snapshot.ExitCode is not null, 3694Assert.NotEqual(0, buildEvent.Snapshot.ExitCode); 3741resourceEvent => resourceEvent.Snapshot.State?.Text == KnownResourceStates.Starting, 3762resourceEvent => resourceEvent.Snapshot.State?.Text == KnownResourceStates.Starting, 3783resourceEvent => DotnetProjectBuildCoordinator.IsSettledBuildSnapshot(resourceEvent.Snapshot), 3785Assert.Equal(KnownResourceStates.Finished, buildEvent.Snapshot.State?.Text); 3786Assert.NotEqual(0, Assert.IsType<int>(buildEvent.Snapshot.ExitCode)); 3793resourceEvent => resourceEvent.Snapshot.State?.Text == KnownResourceStates.FailedToStart, 3795Assert.Equal(KnownResourceStates.FailedToStart, workerEvent.Snapshot.State?.Text);
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)
335r => r.Snapshot.State?.Text == KnownResourceStates.Finished || 336r.Snapshot.State?.Text == KnownResourceStates.Exited || 337r.Snapshot.State?.Text == KnownResourceStates.FailedToStart, 366var snapshot = resourceEvent.Snapshot;
Aspire.Hosting.EntityFrameworkCore.Tests (1)
EFBuildReadinessTests.cs (1)
51Assert.Equal(KnownResourceStates.Finished, state.Snapshot.State?.Text);
Aspire.Hosting.Maui (6)
Lifecycle\MauiBuildQueueEventSubscriber.cs (3)
334e => ShouldReleaseBuildLockForLaunchState(e.Snapshot.State?.Text, stateAtCallTime, releaseOnRunning), 405e => ShouldReleaseBuildLockForLaunchState(e.Snapshot.State?.Text, stateAtCallTime, releaseOnRunning: false), 560e => string.Equals(e.Snapshot.State?.Text, KnownResourceStates.FailedToStart, StringComparisons.ResourceState),
MauiOtlpExtensions.cs (3)
430IsUnavailableState(resourceEvent.Snapshot.State?.Text), 447if (IsUnavailableState(resourceEvent.Snapshot.State?.Text) || 470var endpointUrl = resourceEvent.Snapshot.EnvironmentVariables
Aspire.Hosting.Maui.Tests (3)
MauiBuildQueueTests.cs (3)
131if (evt.Resource.Name == env.MacCatalyst.Name && evt.Snapshot.State?.Text == "Queued") 165if (evt.Resource.Name == env.Android.Name && evt.Snapshot.State?.Text == "Building") 1165if (evt.Resource.Name == resource.Name && evt.Snapshot.State?.Text == state)
Aspire.Hosting.MongoDB (3)
MongoDBSingleMemberReplicaSet.cs (1)
47var isRunning = update.Snapshot.State?.Text == KnownResourceStates.Running;
src\Shared\ContainerReplCommand.cs (2)
29resourceEvent.Snapshot.State?.Text != KnownResourceStates.Running) 35var containerId = GetContainerId(resourceEvent.Snapshot);
Aspire.Hosting.MongoDB.Tests (4)
ReplicaSet\AddMongoDBReplicaSetTests.cs (1)
369return resourceEvent.Snapshot.State?.Text;
SingleMemberReplicaSetFunctionalTests.cs (3)
161update => update.Snapshot.HealthReports.Any(r => r.Name == "mongo_check" && r.Status == HealthStatus.Healthy), ready.Token); 167update => update.Snapshot.State?.Text == KnownResourceStates.Exited, ready.Token); 168Assert.Equal(0, completed.Snapshot.ExitCode);
Aspire.Hosting.MySql (2)
src\Shared\ContainerReplCommand.cs (2)
29resourceEvent.Snapshot.State?.Text != KnownResourceStates.Running) 35var containerId = GetContainerId(resourceEvent.Snapshot);
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 (2)
src\Shared\ContainerReplCommand.cs (2)
29resourceEvent.Snapshot.State?.Text != KnownResourceStates.Running) 35var containerId = GetContainerId(resourceEvent.Snapshot);
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.Redis (2)
src\Shared\ContainerReplCommand.cs (2)
29resourceEvent.Snapshot.State?.Text != KnownResourceStates.Running) 35var containerId = GetContainerId(resourceEvent.Snapshot);
Aspire.Hosting.Redis.Tests (11)
RedisFunctionalTests.cs (11)
122e => e.Snapshot.State == KnownResourceStates.Running, 124var commanderEndpointUri = new Uri(commanderEvent.Snapshot.Urls.First(u => u.Name == "http").Url); 130e => e.Snapshot.Urls.FirstOrDefault(u => u.DisplayProperties.DisplayName == "Manage (Commander)") is { IsInactive: false }, 133var managementUrl = redisEvent.Snapshot.Urls.First(u => u.DisplayProperties.DisplayName == "Manage (Commander)"); 168e => e.Snapshot.State == KnownResourceStates.Running, 171var managementUrl = redisEvent.Snapshot.Urls.FirstOrDefault(u => u.DisplayProperties.DisplayName == "Manage (Commander)"); 180e => e.Snapshot.State == KnownResourceStates.Running, 182Assert.True(commanderEvent.Snapshot.IsHidden); 186e => e.Snapshot.Urls.FirstOrDefault(u => u.DisplayProperties.DisplayName == "Manage (Commander)") is { IsInactive: false }, 191managementUrl = redisEvent.Snapshot.Urls.First(u => u.DisplayProperties.DisplayName == "Manage (Commander)"); 199e => e.Snapshot.Urls.FirstOrDefault(u => u.DisplayProperties.DisplayName == "Manage (Commander)") is { IsInactive: true },
Aspire.Hosting.SqlServer (2)
src\Shared\ContainerReplCommand.cs (2)
29resourceEvent.Snapshot.State?.Text != KnownResourceStates.Running) 35var containerId = GetContainerId(resourceEvent.Snapshot);
Aspire.Hosting.Testing.Tests (2)
DashboardUrlTests.cs (2)
107resourceEvent => resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running, 136resourceEvent => resourceEvent.Snapshot.State?.Text == updatedState,
Aspire.Hosting.Tests (288)
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)
263var resourceEvent = await rns.WaitForResourceAsync(dependentResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Waiting, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 267await rns.WaitForResourceAsync(dependentResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 271await rns.WaitForResourceAsync(dependentResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Finished, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 275await rns.WaitForResourceAsync(dependentResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Waiting, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 279await rns.WaitForResourceAsync(dependentResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 309var notStartedResourceEvent = await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.NotStarted, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 310var dependentResourceEvent = await rns.WaitForResourceAsync(dependentResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Waiting, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 313Assert.Contains("TestProject.ServiceA.csproj", notStartedResourceEvent.Snapshot.Properties.Single(p => p.Name == "project.path").Value?.ToString()); 314Assert.Contains("TestProject.ServiceB.csproj", dependentResourceEvent.Snapshot.Properties.Single(p => p.Name == "project.path").Value?.ToString()); 316Assert.Collection(notStartedResourceEvent.Snapshot.Urls, u => 322Assert.Collection(dependentResourceEvent.Snapshot.Urls, u => 331var runningResourceEvent = await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 332Assert.Collection(runningResourceEvent.Snapshot.Urls, u => 339var dependentResourceRunningEvent = await rns.WaitForResourceAsync(dependentResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 340Assert.Collection(dependentResourceRunningEvent.Snapshot.Urls, u => 352await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Finished, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 356await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 407await rns.WaitForResourceAsync(normalResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, startupToken).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 410await rns.WaitForResourceAsync(explicitStartResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.NotStarted, startupToken).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 451var notStartedResourceEvent = await rns.WaitForResourceAsync(explicitStartResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.NotStarted, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 460await rns.WaitForResourceAsync(explicitStartResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.DefaultOrchestratorTestTimeout); 605e => e.Snapshot.State?.Text == KnownResourceStates.NotStarted, 610e => e.Snapshot.State?.Text == KnownResourceStates.Waiting, 614Assert.Collection(notStartedResourceEvent.Snapshot.Urls, u => 619Assert.Collection(dependentResourceEvent.Snapshot.Urls, u => 627Assert.Equal(RedisImageSource, notStartedResourceEvent.Snapshot.Properties.Single(p => p.Name == "container.image").Value?.ToString()); 628Assert.Contains("TestProject.ServiceB.csproj", dependentResourceEvent.Snapshot.Properties.Single(p => p.Name == "project.path").Value?.ToString()); 632var runningResourceEvent = await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 633Assert.Collection(runningResourceEvent.Snapshot.Urls, u => 639var dependentRunningResourceEvent = await rns.WaitForResourceAsync(dependentResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 640Assert.Collection(dependentRunningResourceEvent.Snapshot.Urls, u => 648await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Exited, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 652await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 694notStartedResourceEvent = await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.NotStarted, token).DefaultTimeout(TestConstants.ExtraLongTimeoutTimeSpan); 695dependentResourceEvent = await rns.WaitForResourceAsync(dependentResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Waiting, token).DefaultTimeout(TestConstants.ExtraLongTimeoutTimeSpan); 697Assert.Collection(notStartedResourceEvent.Snapshot.Urls, u => 702Assert.Collection(dependentResourceEvent.Snapshot.Urls, u => 710Assert.Equal(RedisImageSource, notStartedResourceEvent.Snapshot.Properties.Single(p => p.Name == "container.image").Value?.ToString()); 711Assert.Contains("TestProject.ServiceB.csproj", dependentResourceEvent.Snapshot.Properties.Single(p => p.Name == "project.path").Value?.ToString()); 717var runningResourceEvent = await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.ExtraLongTimeoutTimeSpan); 718Assert.Collection(runningResourceEvent.Snapshot.Urls, u => 724var dependentRunningResourceEvent = await rns.WaitForResourceAsync(dependentResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.ExtraLongTimeoutTimeSpan); 725Assert.Collection(dependentRunningResourceEvent.Snapshot.Urls, u => 733await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Exited, token).DefaultTimeout(TestConstants.ExtraLongTimeoutTimeSpan); 740await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.ExtraLongTimeoutTimeSpan); 1165var dependentRunningResourceEvent = await rns.WaitForResourceAsync(container.Resource.Name, e => e.Snapshot.State?.Text == KnownResourceStates.Running).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 2181var state = e.Snapshot.State?.Text; 2190var state = e.Snapshot.State?.Text; 2226e => e.Snapshot.State?.Text == KnownResourceStates.Running && 2231e => e.Snapshot.State?.Text == KnownResourceStates.Running && 2448return resourceEvent.Snapshot.Properties.FirstOrDefault(p => p.Name == propertyName)?.Value;
ExternalServiceTests.cs (6)
343e => e.Snapshot.State?.Text == KnownResourceStates.FailedToStart 347Assert.Equal(KnownResourceStates.FailedToStart, resourceEvent.Snapshot.State?.Text); 370e => e.Snapshot.State?.Text == KnownResourceStates.FailedToStart 374Assert.Equal(KnownResourceStates.FailedToStart, resourceEvent.Snapshot.State?.Text); 397e => e.Snapshot.State?.Text == KnownResourceStates.Running 401Assert.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 (39)
40Assert.Equal(KnownResourceStates.Finished, @event.ResourceEvent.Snapshot.State?.Text); 41Assert.Equal(0, @event.ResourceEvent.Snapshot.ExitCode); 103childParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 151childParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 252childParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 256nestedChildParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 260child2ParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 321childParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 369projectBParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 519currentState.Snapshot.Properties, 565Assert.Equal(KnownResourceStates.FailedToStart, snapshotEvent.Snapshot.State?.Text); 566Assert.Equal(KnownResourceStateStyles.Error, snapshotEvent.Snapshot.State?.Style); 593Assert.Equal(KnownResourceStates.FailedToStart, snapshotEvent.Snapshot.State?.Text); 594Assert.Null(snapshotEvent.Snapshot.State?.Style); 617Assert.Equal(KnownResourceStates.Starting, snapshotEvent.Snapshot.State?.Text); 649Assert.Equal(KnownResourceStates.Waiting, waitingEvent.Snapshot.State?.Text); 690Assert.NotEqual(KnownResourceStates.Running, dependencyEvent.Snapshot.State?.Text); 738e => e.ResourceId == "waiter-abc123" && e.Snapshot.State?.Text == KnownResourceStates.Waiting, 796e => e.ResourceId == "waiter-abc123" && e.Snapshot.State?.Text == KnownResourceStates.Waiting, 800Assert.Equal(KnownResourceStates.NotStarted, siblingEvent.Snapshot.State?.Text); 847e => e.ResourceId == "waiter-abc123" && e.Snapshot.State?.Text == KnownResourceStates.Waiting, 901e => e.ResourceId == "waiter-abc123" && e.Snapshot.State?.Text == KnownResourceStates.Waiting, 909e => e.ResourceId == "waiter-def456" && e.Snapshot.State?.Text == KnownResourceStates.Waiting, 963Assert.NotEqual(KnownResourceStates.Running, blockerEvent.Snapshot.State?.Text); 1012|| waiterEvent.Snapshot.State?.Text != KnownResourceStates.Waiting) 1029Assert.NotEqual(KnownResourceStates.Running, blockerEvent.Snapshot.State?.Text); 1096re => re.Snapshot.State?.Text == KnownResourceStates.Waiting, 1099var waitingFor = waitingEvent.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.WaitingFor)?.Value; 1365var parentState = resourceNotificationService.TryGetCurrentState("parent-container-dcp", out var parentEvent) ? parentEvent.Snapshot.State?.Text : null; 1366var childContainerState = resourceNotificationService.TryGetCurrentState(childContainer.Resource.Name, out var childContainerEvent) ? childContainerEvent.Snapshot.State?.Text : null; 1367var customChildState = resourceNotificationService.TryGetCurrentState(customChild.Resource.Name, out var customChildEvent) ? customChildEvent.Snapshot.State?.Text : null; 1413var parentState = resourceNotificationService.TryGetCurrentState("parent-container-dcp", out var parentEvent) ? parentEvent.Snapshot.State?.Text : null; 1414var childProjectState = resourceNotificationService.TryGetCurrentState(childProject.Resource.Name, out var childProjectEvent) ? childProjectEvent.Snapshot.State?.Text : null; 1415var customChildState = resourceNotificationService.TryGetCurrentState(customChild.Resource.Name, out var customChildEvent) ? customChildEvent.Snapshot.State?.Text : null; 1462childParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 1466child2ParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 1519childParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 1523child2ParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 1573childProjectParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString();
Orchestrator\ParameterProcessorTests.cs (31)
90updates.Add((resourceEvent.Resource, resourceEvent.Snapshot)); 144Assert.Equal(KnownResourceStates.Running, updates.Current.Snapshot.State?.Text); 145Assert.DoesNotContain(updates.Current.Snapshot.Properties, property => property.Name == KnownProperties.Parameter.Value); 340Assert.Equal(KnownResourceStates.Running, updates.Current.Snapshot.State?.Text); 341AssertParameterValueProperty(updates.Current.Snapshot, "value1", isSensitive: false); 344Assert.Equal(KnownResourceStates.Running, updates.Current.Snapshot.State?.Text); 345AssertParameterValueProperty(updates.Current.Snapshot, "value2", isSensitive: false); 348Assert.Equal(KnownResourceStates.Running, updates.Current.Snapshot.State?.Text); 349AssertParameterValueProperty(updates.Current.Snapshot, "secretValue", isSensitive: true); 2076Assert.Equal(KnownResourceStates.Running, updates.Current.Snapshot.State?.Text); 2077AssertParameterValueProperty(updates.Current.Snapshot, "programmaticValue", isSensitive: false); 2115Assert.Equal(KnownResourceStates.ValueMissing, updates.Current.Snapshot.State?.Text); 2265Assert.Equal(KnownResourceStates.Running, updates.Current.Snapshot.State?.Text); 2266AssertParameterValueProperty(updates.Current.Snapshot, "resourceValue", isSensitive: false); 2283Assert.Equal(KnownResourceStates.ValueMissing, updates.Current.Snapshot.State?.Text); 2295Assert.Equal(KnownResourceStates.Running, updates.Current.Snapshot.State?.Text); 2296AssertParameterValueProperty(updates.Current.Snapshot, "resourceValue", isSensitive: false); 2316Assert.Equal(KnownResourceStates.Running, updates.Current.Snapshot.State?.Text); 2317Assert.DoesNotContain(updates.Current.Snapshot.Properties, property => property.Name == KnownProperties.Parameter.Value); 2333Assert.Equal(KnownResourceStates.ValueMissing, updates.Current.Snapshot.State?.Text); 2345Assert.Equal(KnownResourceStates.Running, updates.Current.Snapshot.State?.Text); 2346Assert.DoesNotContain(updates.Current.Snapshot.Properties, property => property.Name == KnownProperties.Parameter.Value); 2364Assert.Equal(KnownResourceStates.Running, updates.Current.Snapshot.State?.Text); 2371Assert.Equal(KnownResourceStates.ValueMissing, updates.Current.Snapshot.State?.Text); 2416Assert.Equal(clearValue ? KnownResourceStates.ValueMissing : KnownResourceStates.Running, updates.Current.Snapshot.State?.Text); 2429AssertParameterValueProperty(updates.Current.Snapshot, "latestValue", isSensitive: false); 2451Assert.Equal(KnownResourceStates.Running, updates.Current.Snapshot.State?.Text); 2458Assert.Equal(KnownResourceStates.ValueMissing, updates.Current.Snapshot.State?.Text); 2485Assert.Equal(KnownResourceStates.ValueMissing, updates.Current.Snapshot.State?.Text); 2492Assert.Equal(KnownResourceStates.Running, updates.Current.Snapshot.State?.Text); 2493var valueProperty = Assert.Single(updates.Current.Snapshot.Properties, property => property.Name == KnownProperties.Parameter.Value);
ResourceCommandServiceTests.cs (6)
1764await resourceNotificationService.WaitForResourceAsync(project.Resource.Name, e => KnownResourceStates.BuildableStates.Contains(e.Snapshot.State?.Text), cts.Token).DefaultTimeout(TimeSpan.FromMinutes(2)); 1818await resourceNotificationService.WaitForResourceAsync(project.Resource.Name, e => e.ResourceId == replicaName && e.Snapshot.State?.Text == KnownResourceStates.Finished, finishedCts.Token).DefaultTimeout(TimeSpan.FromMinutes(2)); 1829await resourceNotificationService.WaitForResourceAsync(project.Resource.Name, e => e.ResourceId == replicaNames[1] && e.Snapshot.State?.Text == KnownResourceStates.Running, restartCts.Token).DefaultTimeout(TimeSpan.FromMinutes(2)); 1833Assert.Equal(KnownResourceStates.Running, activeReplica.Snapshot.State?.Text); 1840Assert.Equal(KnownResourceStates.Finished, inactiveReplica.Snapshot.State?.Text); 1844await resourceNotificationService.WaitForResourceAsync(project.Resource.Name, e => e.ResourceId == replicaNames[1] && e.Snapshot.State?.Text == KnownResourceStates.Running, runningCts.Token).DefaultTimeout(TimeSpan.FromMinutes(2));
ResourceNotificationTests.cs (82)
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); 419re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 423Assert.Equal(KnownResourceStates.Waiting, waitingEvent.Snapshot.State?.Text); 432re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 446Assert.DoesNotContain(completedWaitingEvent.Snapshot.Properties, p => p.Name == KnownProperties.Resource.WaitingFor); 523re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 527Assert.Equal(KnownResourceStates.Waiting, waitingEvent.Snapshot.State?.Text); 541re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 560Assert.DoesNotContain(completedWaitingEvent.Snapshot.Properties, p => p.Name == KnownProperties.Resource.WaitingFor); 579re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 583Assert.Equal(KnownResourceStates.Waiting, waitingEvent.Snapshot.State?.Text); 593re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 608Assert.DoesNotContain(completedWaitingEvent.Snapshot.Properties, p => p.Name == KnownProperties.Resource.WaitingFor); 633re => re.Snapshot.State?.Text == KnownResourceStates.Waiting, 636Assert.Equal(KnownResourceStates.Waiting, waitingEvent.Snapshot.State?.Text); 679Assert.Equal(state, resourceEvent.Snapshot.State?.Text); 713re => re.ResourceId == "resource-abc123" && re.Snapshot.State?.Text == KnownResourceStates.Waiting, 717Assert.Equal(KnownResourceStates.NotStarted, notStartedEvent.Snapshot.State?.Text); 727Assert.Equal(KnownResourceStates.NotStarted, notStartedEvent.Snapshot.State?.Text); 757Assert.Equal(KnownResourceStates.NotStarted, notStartedEvent.Snapshot.State?.Text); 784re => re.Snapshot.State?.Text == KnownResourceStates.Waiting, 823re => re.ResourceId == "resource-abc123" && re.Snapshot.State?.Text == KnownResourceStates.Waiting, 855re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 868re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 882Assert.DoesNotContain(completedWaitingEvent.Snapshot.Properties, p => p.Name == KnownProperties.Resource.WaitingFor); 898Assert.Contains(waitingEvent.Snapshot.Properties, p => p.Name == KnownProperties.Resource.WaitingFor); 906Assert.DoesNotContain(runningEvent.Snapshot.Properties, p => p.Name == KnownProperties.Resource.WaitingFor); 959re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 1179Assert.Equal("ExistingIcon", firstEvent.Snapshot.IconName); 1180Assert.Equal(IconVariant.Filled, firstEvent.Snapshot.IconVariant); 1184Assert.Equal("ExistingIcon", secondEvent.Snapshot.IconName); 1185Assert.Equal(IconVariant.Filled, secondEvent.Snapshot.IconVariant); 1186Assert.Equal("Running", secondEvent.Snapshot.State?.Text); 1221Assert.Equal("LastIcon", value.Snapshot.IconName); 1222Assert.Equal(IconVariant.Regular, value.Snapshot.IconVariant); 1223Assert.Equal("Starting", value.Snapshot.State?.Text); 1257Assert.Equal("AnnotationIcon", value.Snapshot.IconName); 1258Assert.Equal(IconVariant.Regular, value.Snapshot.IconVariant); 1259Assert.Equal("Starting", value.Snapshot.State?.Text); 1401Assert.Equal(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Healthy, resourceEvent.Snapshot.HealthStatus); 1402Assert.NotNull(resourceEvent.Snapshot.ResourceReadyEvent); 1403Assert.True(resourceEvent.Snapshot.ResourceReadyEvent.EventTask.IsCompletedSuccessfully); 1469Assert.Equal(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Healthy, resourceEvent.Snapshot.HealthStatus); 1494Assert.Equal(HealthStatus.Healthy, resourceEvent.Snapshot.HealthStatus); 1495Assert.True(resourceEvent.Snapshot.ResourceReadyEvent?.EventTask.IsCompletedSuccessfully); 1516return resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running; 1526Assert.Equal(KnownResourceStates.Running, (await waitTask.DefaultTimeout()).Snapshot.State?.Text); 1559return resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running; 1563Assert.Equal(KnownResourceStates.Running, (await waitTask).Snapshot.State?.Text); 1647Assert.True((await waitTask.DefaultTimeout()).Snapshot.ResourceReadyEvent?.EventTask.IsCompletedSuccessfully); 1666Assert.True((await waitTask.DefaultTimeout()).Snapshot.ResourceReadyEvent?.EventTask.IsCompletedSuccessfully); 1763return resourceEvent!.Snapshot.IsHidden; 1812Assert.Equal(initial.Snapshot.Version, unchanged.Snapshot.Version); 1817Assert.True(changed.Snapshot.Version > initial.Snapshot.Version, "A real change should publish a new version."); 1818Assert.Equal("SomeOtherState", changed.Snapshot.State?.Text); 1877Assert.Equal(initial.Snapshot.Version, unchanged.Snapshot.Version); 1890Assert.True(changed.Snapshot.Version > initial.Snapshot.Version, "A changed value inside a List<T> property should publish a new version."); 1909Assert.Equal(initial.Snapshot.Version, unchanged.Snapshot.Version); 1930changed.Snapshot.Version > initial.Snapshot.Version, 1962changed.Snapshot.Version > initial.Snapshot.Version, 1968var 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 (32)
120if (notification.Resource == custom.Resource && notification.Snapshot.Urls.Length > 0) 122urlSnapshots.Add(notification.Snapshot.Urls.ToArray()); 123TestOutputHelper.WriteLine($"Captured snapshot #{urlSnapshots.Count}: State={notification.Snapshot.State}, URLs: {FormatUrls(notification.Snapshot.Urls)}"); 126if (notification.Snapshot.State == KnownResourceStates.Running && 127notification.Snapshot.Urls.All(u => !u.IsInactive)) 618e => e.Snapshot.Urls.Length == 1).DefaultTimeout(); 622Assert.Single(resourceEvent.Snapshot.Urls, s => s.Name == httpEndpoint.EndpointName && s.IsInactive && s.Url == "https://example.com"); 643e => e.Snapshot.Urls.Length == 3).DefaultTimeout(); 647Assert.Collection(resourceEvent.Snapshot.Urls, 676e => e.Snapshot.State == KnownResourceStates.Running 677&& e.Snapshot.Urls.Length == 2 678&& e.Snapshot.Urls.All(url => !url.IsInactive)).DefaultTimeout(); 682Assert.Equal(2, resourceEvent.Snapshot.Urls.Length); 683Assert.Collection(resourceEvent.Snapshot.Urls, 709if (notification.Resource == servicea.Resource && notification.Snapshot.Urls.Length > 0) 711urlSnapshots.Add(notification.Snapshot.Urls.ToArray()); 712TestOutputHelper.WriteLine($"Captured snapshot #{urlSnapshots.Count}: State={notification.Snapshot.State}, URLs: {FormatUrls(notification.Snapshot.Urls)}"); 715if (notification.Snapshot.State == KnownResourceStates.Running && 716notification.Snapshot.Urls.All(u => !u.IsInactive)) 786e => e.Snapshot.State == KnownResourceStates.Running && e.Snapshot.Urls.Length == 4).DefaultTimeout(); 790Assert.Collection(resourceEvent.Snapshot.Urls, 1119e => e.Snapshot.State == KnownResourceStates.Running 1120&& e.Snapshot.Urls.Length == resourceB.Resource.GetEndpoints().ToArray().Length + 1 1121&& e.Snapshot.Urls.All(u => !u.IsInactive), 1133var crossResourceUrl = resourceEvent.Snapshot.Urls.FirstOrDefault(u => u.DisplayProperties.DisplayName == "API Docs"); 1171e => e.Snapshot.State == KnownResourceStates.Running, 1174var crossResourceUrl = resourceEvent.Snapshot.Urls.FirstOrDefault(u => u.DisplayProperties.DisplayName == "API Docs"); 1186e => e.Snapshot.Urls.FirstOrDefault(u => u.DisplayProperties.DisplayName == "API Docs") is { IsInactive: false }, 1195e => e.Snapshot.Urls.FirstOrDefault(u => u.DisplayProperties.DisplayName == "API Docs") is { IsInactive: true },
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.Hosting.Valkey (2)
src\Shared\ContainerReplCommand.cs (2)
29resourceEvent.Snapshot.State?.Text != KnownResourceStates.Running) 35var containerId = GetContainerId(resourceEvent.Snapshot);
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);