759 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) 1359if (TryGetCurrentState(resourceName, out var evt) && evt.Snapshot != null) 1361var snapshot = evt.Snapshot; 1401error.Append(CultureInfo.InvariantCulture, $" - {dependencyName}: State = {dependencyEvent.Snapshot.State?.Text ?? "(null)"}"); 1402error.Append(CultureInfo.InvariantCulture, $", Health = {dependencyEvent.Snapshot.HealthStatus?.ToString() ?? "(null)"}"); 1403if (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; 1766return 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) 56var transformedUrls = from originalUrl in resourceEvent.Snapshot.Urls
Diagnostics\ProfilingTelemetry.cs (1)
1098var snapshot = resourceEvent.Snapshot;
DistributedApplication.cs (1)
850results.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 (143)
AzureBicepProvisionerTests.cs (28)
818AssertHighlightedContextProperty(resourceEvent.Snapshot.Properties, "azure.subscription.id", "12345678-1234-1234-1234-123456789012", AzureProvisioningStrings.ContextPropertySubscriptionIdDisplayName); 819AssertHighlightedContextProperty(resourceEvent.Snapshot.Properties, "azure.resource.group", "test-rg", AzureProvisioningStrings.ContextPropertyResourceGroupDisplayName); 820AssertHighlightedContextProperty(resourceEvent.Snapshot.Properties, "azure.tenant.id", "87654321-4321-4321-4321-210987654321", AzureProvisioningStrings.ContextPropertyTenantIdDisplayName); 821AssertHighlightedContextProperty(resourceEvent.Snapshot.Properties, "azure.tenant.domain", "testdomain.onmicrosoft.com", AzureProvisioningStrings.ContextPropertyTenantDomainDisplayName); 822AssertHighlightedContextProperty(resourceEvent.Snapshot.Properties, "azure.location", "westus3", AzureProvisioningStrings.ContextPropertyLocationDisplayName); 823Assert.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()); 852Assert.Equal("87654321-4321-4321-4321-210987654321", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.tenant.id").Value?.ToString()); 853Assert.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()); 890Assert.Equal("87654321-4321-4321-4321-210987654321", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.tenant.id").Value?.ToString()); 891Assert.Equal(expectedDeploymentId, resourceEvent.Snapshot.Properties.Single(p => p.Name == CustomResourceKnownProperties.Source).Value?.ToString()); 892Assert.Equal(BicepProvisioner.GetDeploymentUrl(new ResourceIdentifier(expectedDeploymentId)), resourceEvent.Snapshot.Urls.Single(u => u.Name == "deployment").Url); 1004Assert.Equal("12345678-1234-1234-1234-123456789012", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.subscription.id").Value?.ToString()); 1005Assert.Equal("test-rg", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.resource.group").Value?.ToString()); 1006Assert.Equal("87654321-4321-4321-4321-210987654321", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.tenant.id").Value?.ToString()); 1007Assert.Equal("microsoft.onmicrosoft.com", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.tenant.domain").Value?.ToString()); 1008Assert.Equal("westus2", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.location").Value?.ToString()); 1009Assert.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()); 1055Assert.Equal("scoped-rg", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.resource.group").Value?.ToString()); 1246Assert.Equal("Azure deployment failed", resourceEvent.Snapshot.State?.Text); 1248resourceEvent.Snapshot.Properties, 1292resourceEvent.Snapshot.Properties.Where(static property => 1361Assert.Equal("Azure deployment failed", resourceEvent.Snapshot.State?.Text); 1362Assert.DoesNotContain(resourceEvent.Snapshot.Properties, p => p.Name.StartsWith("azure.deployment.operations.", StringComparison.Ordinal)); 1363Assert.Equal(AzureProvisioningFailureDetails.LocationNotAvailableForResourceTypeErrorCode, resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.code").Value); 1364Assert.Equal("australiacentral", resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.current.location").Value); 1365var supportedLocations = Assert.IsType<string[]>(resourceEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.supported.locations").Value); 1829Assert.Equal("Azure deployment canceled", resourceEvent.Snapshot.State?.Text); 1868var property = Assert.Single(resourceEvent.Snapshot.Properties, p => p.Name == "azure.resource.group");
AzureEnvironmentResourceExtensionsTests.cs (113)
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); 818Assert.Equal(KnownResourceStates.Running, resourceEvent.Snapshot.State?.Text); 891Assert.Equal(KnownResourceStates.Running, storageEvent.Snapshot.State?.Text); 1052AssertCommandState(keyVaultEvent.Snapshot, AzureProvisioningController.ChangeResourceLocationCommandName, ResourceCommandState.Hidden); 1053AssertCommandState(keyVaultEvent.Snapshot, AzureProvisioningController.GetAzureResourceCommandName, ResourceCommandState.Enabled); 1054AssertCommandState(keyVaultEvent.Snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Hidden); 1055AssertCommandState(keyVaultEvent.Snapshot, AzureProvisioningController.DeleteAzureResourceCommandName, ResourceCommandState.Enabled); 1056AssertCommandState(keyVaultEvent.Snapshot, AzureProvisioningController.ForgetStateCommandName, ResourceCommandState.Enabled); 1057AssertCommandState(keyVaultEvent.Snapshot, AzureProvisioningController.ReprovisionResourceCommandName, ResourceCommandState.Enabled); 1087AssertCommandState(postgresEvent.Snapshot, AzureProvisioningController.ChangeResourceLocationCommandName, ResourceCommandState.Enabled); 1729Assert.Equal("Canceled", storageEvent.Snapshot.State?.Text); 1765AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.ChangeResourceLocationCommandName, ResourceCommandState.Disabled); 1766AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.GetAzureResourceCommandName, ResourceCommandState.Enabled); 1767AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Enabled); 1768AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.DeleteAzureResourceCommandName, ResourceCommandState.Disabled); 1769AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.ForgetStateCommandName, ResourceCommandState.Disabled); 1770AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.ReprovisionResourceCommandName, ResourceCommandState.Disabled); 1842AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Enabled); 2012var cancelCommand = Assert.Single(storageEvent.Snapshot.Commands, c => c.Name == AzureProvisioningController.CancelCommandName); 2067Assert.Equal(KnownResourceStates.Running, storageEvent.Snapshot.State?.Text); 2170Assert.Equal(KnownResourceStates.NotStarted, storageEvent.Snapshot.State?.Text); 2173Assert.Equal(KnownResourceStates.Running, storage2Event.Snapshot.State?.Text); 2252Assert.Equal(KnownResourceStates.NotStarted, keyVaultEvent.Snapshot.State?.Text); 2315Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Disabled, command.State)); 2318Assert.Equal("Deleting", storageEvent.Snapshot.State?.Text); 2319AssertAffectedResourceCommandsDuringOperation(storageEvent.Snapshot); 2322AssertUnaffectedResourceCommandsDuringOperation(storage2Event.Snapshot); 2406Assert.Equal("Canceled", storageEvent.Snapshot.State?.Text); 2479Assert.Equal(KnownResourceStates.NotStarted, storageEvent.Snapshot.State?.Text); 2480Assert.DoesNotContain(storageEvent.Snapshot.Properties, p => p.Name == CustomResourceKnownProperties.Source); 2481Assert.Contains(storageEvent.Snapshot.Properties, p => p.Name == "custom.property"); 2484Assert.Equal(KnownResourceStates.Running, storage2Event.Snapshot.State?.Text); 2485Assert.Contains(storage2Event.Snapshot.Properties, p => p.Name == CustomResourceKnownProperties.Source); 2541Assert.Equal("Running", storageEvent.Snapshot.State?.Text); 2544Assert.Equal(KnownResourceStates.Running, storage2Event.Snapshot.State?.Text); 2590Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Disabled, command.State)); 2593AssertAffectedResourceCommandsDuringOperation(storageEvent.Snapshot); 2596AssertUnaffectedResourceCommandsDuringOperation(storage2Event.Snapshot); 2604Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Enabled, command.State)); 2607AssertUnaffectedResourceCommandsDuringOperation(storageEvent.Snapshot); 2650Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Disabled, command.State)); 2653AssertAffectedResourceCommandsDuringOperation(storageEvent.Snapshot); 2662Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Enabled, command.State)); 2665AssertUnaffectedResourceCommandsDuringOperation(storageEvent.Snapshot); 2804AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Enabled); 2821Assert.Equal("Canceling", storageEvent.Snapshot.State?.Text); 2822AssertCommandState(storageEvent.Snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Disabled); 2824Assert.Equal("Canceling", blobsEvent.Snapshot.State?.Text); 2833Assert.Equal("Canceled", storageEvent.Snapshot.State?.Text); 2834Assert.DoesNotContain(storageEvent.Snapshot.Properties, p => p.Name == AzureResourceProperties.OperationName); 2883AssertCommandState(runningStorage2Event.Snapshot, AzureProvisioningController.CancelCommandName, ResourceCommandState.Hidden); 2900storageEvent.Snapshot.State?.Text is "Canceling" or "Canceled", 2901$"Expected storage to be canceling or canceled, but it was '{storageEvent.Snapshot.State?.Text}'."); 2903Assert.Equal("Running", storage2Event.Snapshot.State?.Text); 2908Assert.Equal("Running", storage2Event.Snapshot.State?.Text); 3070Assert.All(environmentEvent.Snapshot.Commands, command => Assert.Equal(ResourceCommandState.Disabled, command.State)); 3073var storageSnapshot = storageEvent.Snapshot; 3082AssertUnaffectedResourceCommandsDuringOperation(storage2Event.Snapshot); 3083Assert.DoesNotContain(storage2Event.Snapshot.Properties, property => property.Name == AzureResourceProperties.OperationName); 3383Assert.Equal(KnownResourceStates.Running, storageEvent.Snapshot.State?.Text); 3828Assert.Equal(KnownResourceStates.Running, environmentEvent.Snapshot.State?.Text); 3829AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.subscription.id", "12345678-1234-1234-1234-123456789012", AzureProvisioningStrings.ContextPropertySubscriptionIdDisplayName); 3830AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.resource.group", "cli-rg-é", AzureProvisioningStrings.ContextPropertyResourceGroupDisplayName); 3831AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.location", "westus3", AzureProvisioningStrings.ContextPropertyLocationDisplayName); 3832AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.tenant.id", "87654321-4321-4321-4321-210987654321", AzureProvisioningStrings.ContextPropertyTenantIdDisplayName); 3881Assert.DoesNotContain(environmentEvent.Snapshot.Properties, p => p.Name == "azure.tenant.id"); 4279Assert.Equal("Running", keyVaultEvent.Snapshot.State?.Text); 4383Assert.Equal("Failed to Provision", keyVaultEvent.Snapshot.State?.Text); 4384Assert.Equal(AzureProvisioningFailureDetails.KeyVaultDeletedStateTombstoneNotFoundReason, keyVaultEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.code").Value?.ToString()); 4385var snapshotRecommendedActions = Assert.IsType<string[]>(keyVaultEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.recommendedActions").Value); 4590Assert.Equal("Failed to Provision", storageEvent.Snapshot.State?.Text); 4592storageEvent.Snapshot.Properties.Where(property => AzureProvisioningFailureDetails.IsFailureProperty(property.Name)), 4598Assert.Equal("Microsoft.ManagedIdentity", storageEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.provider").Value?.ToString()); 4599Assert.Equal("Microsoft.ManagedIdentity/userAssignedIdentities", storageEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.resource.type").Value?.ToString()); 4600Assert.Equal("LocationNotAvailableForResourceType", storageEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.code").Value?.ToString()); 4601Assert.Equal(400, storageEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.http.status").Value); 4602var snapshotRecommendedActions = Assert.IsType<string[]>(storageEvent.Snapshot.Properties.Single(p => p.Name == "azure.provisioning.error.recommendedActions").Value); 4676Assert.Equal(AzureProvisioningController.DriftedState, environmentEvent.Snapshot.State?.Text); 4677Assert.Equal(KnownResourceStateStyles.Error, environmentEvent.Snapshot.State?.Style); 4678AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.subscription.id", "12345678-1234-1234-1234-123456789012", AzureProvisioningStrings.ContextPropertySubscriptionIdDisplayName); 4679AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.resource.group", "test-rg", AzureProvisioningStrings.ContextPropertyResourceGroupDisplayName); 4680AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.location", "westus2", AzureProvisioningStrings.ContextPropertyLocationDisplayName); 4681AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.tenant.id", "87654321-4321-4321-4321-210987654321", AzureProvisioningStrings.ContextPropertyTenantIdDisplayName); 4682AssertHighlightedContextProperty(environmentEvent.Snapshot.Properties, "azure.tenant.domain", "testdomain.onmicrosoft.com", AzureProvisioningStrings.ContextPropertyTenantDomainDisplayName); 4685Assert.Equal(AzureProvisioningController.MissingInAzureState, resourceEvent.Snapshot.State?.Text); 4686Assert.Equal(KnownResourceStateStyles.Error, resourceEvent.Snapshot.State?.Style); 4729Assert.Equal(KnownResourceStates.Running, environmentEvent.Snapshot.State?.Text); 4732Assert.Equal(KnownResourceStates.Running, resourceEvent.Snapshot.State?.Text); 4788Assert.Equal(AzureProvisioningController.DriftedState, environmentEvent.Snapshot.State?.Text); 4791Assert.Equal(KnownResourceStates.Running, storageEvent.Snapshot.State?.Text); 4794Assert.Equal(AzureProvisioningController.MissingInAzureState, storage2Event.Snapshot.State?.Text); 4795Assert.Equal(KnownResourceStateStyles.Error, storage2Event.Snapshot.State?.Style); 4831Assert.Equal(KnownResourceStates.Running, environmentEvent.Snapshot.State?.Text); 4834Assert.Equal(KnownResourceStates.Running, resourceEvent.Snapshot.State?.Text); 5028Assert.Equal("Failed to Delete", environmentEvent.Snapshot.State?.Text); 5095Assert.Equal("Failed to Provision", storageEvent.Snapshot.State?.Text); 5098Assert.Equal("Failed to Provision", storageRolesEvent.Snapshot.State?.Text); 5166Assert.Equal(AzureProvisioningController.CancelingState, storageEvent.Snapshot.State?.Text); 5172Assert.Equal(AzureProvisioningStrings.ResourceStateCanceled, storageEvent.Snapshot.State?.Text); 5173Assert.Equal(KnownResourceStateStyles.Info, storageEvent.Snapshot.State?.Style); 5196Assert.Equal("Failed to Provision", environmentEvent.Snapshot.State?.Text); 5198var failedResourcesProperty = Assert.Single(environmentEvent.Snapshot.Properties, property => property.Name == "azure.provisioning.error.failed.resources"); 5514resourceEvent.Snapshot.State?.Text == expectedState) 5530? finalEvent.Snapshot.State?.Text
DurableTaskResourceExtensionsTests.cs (2)
65var url = Assert.Single(resourceEvent.Snapshot.Urls); 83Assert.Empty(resourceEvent.Snapshot.Urls);
Aspire.Hosting.Blazor (6)
BlazorGatewayExtensions.cs (3)
523var gatewayState = resourceEvent.Snapshot.State; 536StartTimeStamp = resourceEvent.Snapshot.StartTimeStamp, 537StopTimeStamp = 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)
746&& previous.Snapshot.State?.Text == KnownResourceStates.Running 747&& previous.Snapshot.HealthStatus == HealthStatus.Healthy; 808? current.Snapshot.Properties.FirstOrDefault(p => p.Name == "Anonymous access")?.Value as string 829&& KnownResourceStates.TerminalStates.Contains(current.Snapshot.State?.Text))
Aspire.Hosting.DevTunnels.Tests (17)
DevTunnelResourceBuilderExtensionsTests.cs (14)
324e => e.Snapshot.Properties.Any(p => p.Name == "Anonymous access")).DefaultTimeout(); 388e => e.Snapshot.Properties.Any(p => p.Name == "Anonymous access")).DefaultTimeout(); 822e => e.Snapshot.Urls.Any(u => u.Url == inspectUrl) 823&& e.Snapshot.Urls.Any(u => u.Url == "https://example.com/diagnostics") 824&& e.Snapshot.Urls.All(u => u.IsInactive == expectedInactive), cts.Token); 825Assert.Equal(restartBeforeUrlCallbackCompletes ? KnownResourceStates.Running : KnownResourceStates.Finished, completed.Snapshot.State?.Text); 826Assert.True(completed.Snapshot.Urls.Length >= 3); 833Assert.NotNull(completed.Snapshot.StopTimeStamp); 845e => e.Snapshot.State?.Text == KnownResourceStates.Running && 846e.Snapshot.Urls.Any(u => u.Url == tunnelUrl && !u.IsInactive) && 847e.Snapshot.Urls.Any(u => u.Url == inspectUrl && !u.IsInactive), 853Assert.Contains(resourceEvent.Snapshot.Urls, u => u.Url == tunnelUrl && !u.IsInactive); 854Assert.Contains(resourceEvent.Snapshot.Urls, u => u.Url == inspectUrl && !u.IsInactive); 893resourceEvent.Snapshot.Properties.Where(p => p.Name is
TestDevTunnelMonitor.cs (3)
89e => e.Snapshot.State?.Text == KnownResourceStates.Running && e.Snapshot.HealthStatus == Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Healthy).DefaultTimeout(); 95return current.Snapshot;
Aspire.Hosting.Dotnet (14)
DotnetProjectBuildCoordinator.cs (14)
213resourceEvent => IsSettledBuildSnapshot(resourceEvent.Snapshot), 216if (buildEvent.Snapshot.State?.Text != KnownResourceStates.FailedToStart && 217buildEvent.Snapshot.ExitCode is 0) 227var messageTask = failureState.GetFailureMessage(attempt, services, buildResource, buildEvent.Snapshot); 267IsFailedBuildSnapshot(current.Snapshot)) 270failureState.GetFailureMessage(attempt, @event.Services, @event.Resource, current.Snapshot); 519rebuildEvent.Snapshot.State?.Text is { } state && 1225? resourceEvent.Snapshot 1305? resourceEvent.Snapshot 1527!ReferenceEquals(resourceEvent.Snapshot, initialSnapshot) && 1528IsSettledBuildSnapshot(resourceEvent.Snapshot), 1559!ReferenceEquals(resourceEvent.Snapshot, initialSnapshot) && 1560(resourceEvent.Snapshot.State?.Text == KnownResourceStates.FailedToStart || 1561KnownResourceStates.TerminalStates.Contains(resourceEvent.Snapshot.State?.Text)),
Aspire.Hosting.Dotnet.Tests (29)
DotnetProjectBuildCoordinatorTests.cs (29)
940resourceEvent.Snapshot.State?.Text == KnownResourceStates.Finished && 941resourceEvent.Snapshot.ExitCode is not null, 946resourceEvent.Snapshot.State?.Text == KnownResourceStates.Finished && 947resourceEvent.Snapshot.ExitCode is not null, 949Assert.All(completionEvents, resourceEvent => Assert.Equal(0, resourceEvent.Snapshot.ExitCode)); 2247resourceEvent => DotnetProjectBuildCoordinator.IsSettledBuildSnapshot(resourceEvent.Snapshot), 2249Assert.NotEqual(0, buildEvent.Snapshot.ExitCode); 3814resourceEvent => resourceEvent.ResourceId == name && resourceEvent.Snapshot.State?.Text == KnownResourceStates.Finished, 3818var properties = completedResource.Snapshot.Properties; 3819Assert.Equal("Project", completedResource.Snapshot.ResourceType); 3870resourceEvent => resourceEvent.ResourceId == name && resourceEvent.Snapshot.State?.Text == KnownResourceStates.FailedToStart, 3917resourceEvent => DotnetProjectBuildCoordinator.IsSettledBuildSnapshot(resourceEvent.Snapshot), 3923Assert.Equal(0, secondBuildEvent.Snapshot.ExitCode); 3966resourceEvent => DotnetProjectBuildCoordinator.IsSettledBuildSnapshot(resourceEvent.Snapshot), 3970resourceEvent => DotnetProjectBuildCoordinator.IsSettledBuildSnapshot(resourceEvent.Snapshot), 3977Assert.Equal(KnownResourceStates.Finished, firstBuildEvent.Snapshot.State?.Text); 3978Assert.NotEqual(0, Assert.IsType<int>(firstBuildEvent.Snapshot.ExitCode)); 3979Assert.Equal(KnownResourceStates.FailedToStart, secondBuildEvent.Snapshot.State?.Text); 4258Assert.Equal(KnownResourceStates.NotStarted, projectEvent.Snapshot.State?.Text); 4676KnownResourceStates.TerminalStates.Contains(resourceEvent.Snapshot.State?.Text) && 4677resourceEvent.Snapshot.ExitCode is not null, 4684Assert.NotEqual(0, buildEvent.Snapshot.ExitCode); 4731resourceEvent => resourceEvent.Snapshot.State?.Text == KnownResourceStates.Starting, 4752resourceEvent => resourceEvent.Snapshot.State?.Text == KnownResourceStates.Starting, 4773resourceEvent => DotnetProjectBuildCoordinator.IsSettledBuildSnapshot(resourceEvent.Snapshot), 4775Assert.Equal(KnownResourceStates.Finished, buildEvent.Snapshot.State?.Text); 4776Assert.NotEqual(0, Assert.IsType<int>(buildEvent.Snapshot.ExitCode)); 4783resourceEvent => resourceEvent.Snapshot.State?.Text == KnownResourceStates.FailedToStart, 4785Assert.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)
52Assert.Equal(KnownResourceStates.Finished, state.Snapshot.State?.Text);
Aspire.Hosting.Maui (6)
Lifecycle\MauiBuildQueueEventSubscriber.cs (3)
338e => ShouldReleaseBuildLockForLaunchState(e.Snapshot.State?.Text, stateAtCallTime, releaseOnRunning), 409e => ShouldReleaseBuildLockForLaunchState(e.Snapshot.State?.Text, stateAtCallTime, releaseOnRunning: false), 564e => 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 (1)
MauiBuildQueueTests.cs (1)
1186env.NotificationService.WaitForResourceAsync(resource.Name, evt => evt.Snapshot.State?.Text == state).DefaultTimeout();
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, 134resourceEvent => resourceEvent.Snapshot.State?.Text == updatedState,
Aspire.Hosting.Tests (300)
Codespaces\CodespacesUrlRewriterTests.cs (3)
105var match = re.Snapshot.Urls.Length > 0 && re.Snapshot.Urls[0].Url.Contains("app.github.dev"); 111resourceEvent.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); 408var normalResource = await rns.WaitForResourceAsync(normalResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, startupToken).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 411await rns.WaitForResourceAsync(explicitStartResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.NotStarted, startupToken).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 470var notStartedResourceEvent = await rns.WaitForResourceAsync(explicitStartResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.NotStarted, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 479await rns.WaitForResourceAsync(explicitStartResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.DefaultOrchestratorTestTimeout); 624e => e.Snapshot.State?.Text == KnownResourceStates.NotStarted, 629e => e.Snapshot.State?.Text == KnownResourceStates.Waiting, 633Assert.Collection(notStartedResourceEvent.Snapshot.Urls, u => 638Assert.Collection(dependentResourceEvent.Snapshot.Urls, u => 646Assert.Equal(RedisImageSource, notStartedResourceEvent.Snapshot.Properties.Single(p => p.Name == "container.image").Value?.ToString()); 647Assert.Contains("TestProject.ServiceB.csproj", dependentResourceEvent.Snapshot.Properties.Single(p => p.Name == "project.path").Value?.ToString()); 651var runningResourceEvent = await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 652Assert.Collection(runningResourceEvent.Snapshot.Urls, u => 658var dependentRunningResourceEvent = await rns.WaitForResourceAsync(dependentResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 659Assert.Collection(dependentRunningResourceEvent.Snapshot.Urls, u => 667await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Exited, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 671await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 713notStartedResourceEvent = await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.NotStarted, token).DefaultTimeout(TestConstants.ExtraLongTimeoutTimeSpan); 714dependentResourceEvent = await rns.WaitForResourceAsync(dependentResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Waiting, token).DefaultTimeout(TestConstants.ExtraLongTimeoutTimeSpan); 716Assert.Collection(notStartedResourceEvent.Snapshot.Urls, u => 721Assert.Collection(dependentResourceEvent.Snapshot.Urls, u => 729Assert.Equal(RedisImageSource, notStartedResourceEvent.Snapshot.Properties.Single(p => p.Name == "container.image").Value?.ToString()); 730Assert.Contains("TestProject.ServiceB.csproj", dependentResourceEvent.Snapshot.Properties.Single(p => p.Name == "project.path").Value?.ToString()); 736var runningResourceEvent = await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.ExtraLongTimeoutTimeSpan); 737Assert.Collection(runningResourceEvent.Snapshot.Urls, u => 743var dependentRunningResourceEvent = await rns.WaitForResourceAsync(dependentResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.ExtraLongTimeoutTimeSpan); 744Assert.Collection(dependentRunningResourceEvent.Snapshot.Urls, u => 752await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Exited, token).DefaultTimeout(TestConstants.ExtraLongTimeoutTimeSpan); 759await rns.WaitForResourceAsync(notStartedResourceName, e => e.Snapshot.State?.Text == KnownResourceStates.Running, token).DefaultTimeout(TestConstants.ExtraLongTimeoutTimeSpan); 1184var dependentRunningResourceEvent = await rns.WaitForResourceAsync(container.Resource.Name, e => e.Snapshot.State?.Text == KnownResourceStates.Running).DefaultTimeout(TestConstants.LongTimeoutTimeSpan); 2200var state = e.Snapshot.State?.Text; 2209var state = e.Snapshot.State?.Text; 2245e => e.Snapshot.State?.Text == KnownResourceStates.Running && 2250e => e.Snapshot.State?.Text == KnownResourceStates.Running && 2467return 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 (40)
195Assert.Equal([$"{origin}/path?x=1#fragment", $"{origin}/secondary"], state.Snapshot.Urls.Select(url => url.Url)); 544Assert.Equal(KnownResourceStates.Finished, @event.ResourceEvent.Snapshot.State?.Text); 545Assert.Equal(0, @event.ResourceEvent.Snapshot.ExitCode); 607childParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 655childParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 756childParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 760nestedChildParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 764child2ParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 825childParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 873projectBParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 1023currentState.Snapshot.Properties, 1069Assert.Equal(KnownResourceStates.FailedToStart, snapshotEvent.Snapshot.State?.Text); 1070Assert.Equal(KnownResourceStateStyles.Error, snapshotEvent.Snapshot.State?.Style); 1097Assert.Equal(KnownResourceStates.FailedToStart, snapshotEvent.Snapshot.State?.Text); 1098Assert.Null(snapshotEvent.Snapshot.State?.Style); 1121Assert.Equal(KnownResourceStates.Starting, snapshotEvent.Snapshot.State?.Text); 1153Assert.Equal(KnownResourceStates.Waiting, waitingEvent.Snapshot.State?.Text); 1194Assert.NotEqual(KnownResourceStates.Running, dependencyEvent.Snapshot.State?.Text); 1242e => e.ResourceId == "waiter-abc123" && e.Snapshot.State?.Text == KnownResourceStates.Waiting, 1300e => e.ResourceId == "waiter-abc123" && e.Snapshot.State?.Text == KnownResourceStates.Waiting, 1304Assert.Equal(KnownResourceStates.NotStarted, siblingEvent.Snapshot.State?.Text); 1351e => e.ResourceId == "waiter-abc123" && e.Snapshot.State?.Text == KnownResourceStates.Waiting, 1405e => e.ResourceId == "waiter-abc123" && e.Snapshot.State?.Text == KnownResourceStates.Waiting, 1413e => e.ResourceId == "waiter-def456" && e.Snapshot.State?.Text == KnownResourceStates.Waiting, 1467Assert.NotEqual(KnownResourceStates.Running, blockerEvent.Snapshot.State?.Text); 1516|| waiterEvent.Snapshot.State?.Text != KnownResourceStates.Waiting) 1533Assert.NotEqual(KnownResourceStates.Running, blockerEvent.Snapshot.State?.Text); 1600re => re.Snapshot.State?.Text == KnownResourceStates.Waiting, 1603var waitingFor = waitingEvent.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.WaitingFor)?.Value; 1869var parentState = resourceNotificationService.TryGetCurrentState("parent-container-dcp", out var parentEvent) ? parentEvent.Snapshot.State?.Text : null; 1870var childContainerState = resourceNotificationService.TryGetCurrentState(childContainer.Resource.Name, out var childContainerEvent) ? childContainerEvent.Snapshot.State?.Text : null; 1871var customChildState = resourceNotificationService.TryGetCurrentState(customChild.Resource.Name, out var customChildEvent) ? customChildEvent.Snapshot.State?.Text : null; 1917var parentState = resourceNotificationService.TryGetCurrentState("parent-container-dcp", out var parentEvent) ? parentEvent.Snapshot.State?.Text : null; 1918var childProjectState = resourceNotificationService.TryGetCurrentState(childProject.Resource.Name, out var childProjectEvent) ? childProjectEvent.Snapshot.State?.Text : null; 1919var customChildState = resourceNotificationService.TryGetCurrentState(customChild.Resource.Name, out var customChildEvent) ? customChildEvent.Snapshot.State?.Text : null; 1966childParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 1970child2ParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 2023childParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 2027child2ParentResourceId = item.Snapshot.Properties.SingleOrDefault(p => p.Name == KnownProperties.Resource.ParentName)?.Value?.ToString(); 2077childProjectParentResourceId = 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); 2256Assert.Equal(KnownResourceStates.Running, updates.Current.Snapshot.State?.Text); 2257AssertParameterValueProperty(updates.Current.Snapshot, "programmaticValue", isSensitive: false); 2295Assert.Equal(KnownResourceStates.ValueMissing, updates.Current.Snapshot.State?.Text); 2445Assert.Equal(KnownResourceStates.Running, updates.Current.Snapshot.State?.Text); 2446AssertParameterValueProperty(updates.Current.Snapshot, "resourceValue", isSensitive: false); 2463Assert.Equal(KnownResourceStates.ValueMissing, updates.Current.Snapshot.State?.Text); 2475Assert.Equal(KnownResourceStates.Running, updates.Current.Snapshot.State?.Text); 2476AssertParameterValueProperty(updates.Current.Snapshot, "resourceValue", isSensitive: false); 2496Assert.Equal(KnownResourceStates.Running, updates.Current.Snapshot.State?.Text); 2497Assert.DoesNotContain(updates.Current.Snapshot.Properties, property => property.Name == KnownProperties.Parameter.Value); 2513Assert.Equal(KnownResourceStates.ValueMissing, updates.Current.Snapshot.State?.Text); 2525Assert.Equal(KnownResourceStates.Running, updates.Current.Snapshot.State?.Text); 2526Assert.DoesNotContain(updates.Current.Snapshot.Properties, property => property.Name == KnownProperties.Parameter.Value); 2544Assert.Equal(KnownResourceStates.Running, updates.Current.Snapshot.State?.Text); 2551Assert.Equal(KnownResourceStates.ValueMissing, updates.Current.Snapshot.State?.Text); 2596Assert.Equal(clearValue ? KnownResourceStates.ValueMissing : KnownResourceStates.Running, updates.Current.Snapshot.State?.Text); 2609AssertParameterValueProperty(updates.Current.Snapshot, "latestValue", isSensitive: false); 2631Assert.Equal(KnownResourceStates.Running, updates.Current.Snapshot.State?.Text); 2638Assert.Equal(KnownResourceStates.ValueMissing, updates.Current.Snapshot.State?.Text); 2665Assert.Equal(KnownResourceStates.ValueMissing, updates.Current.Snapshot.State?.Text); 2672Assert.Equal(KnownResourceStates.Running, updates.Current.Snapshot.State?.Text); 2673var 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 (93)
92Assert.Equal(expectedResourceType, resourceEvent.Snapshot.ResourceType); 93Assert.Equal(expectedResourceType, resourceEvent.Snapshot.ResourceTypeDisplayName); 115Assert.Equal(expectedType, resourceEvent.Snapshot.ResourceType); 116Assert.Equal(expectedService, resourceEvent.Snapshot.ResourceTypeDisplayName); 137Assert.Equal("Container", resourceEvent.Snapshot.ResourceType); 138Assert.Equal("Shared cache", resourceEvent.Snapshot.ResourceTypeDisplayName); 151Assert.Equal("Project", resourceEvent.Snapshot.ResourceType); 152Assert.Equal("Orders API", resourceEvent.Snapshot.ResourceTypeDisplayName); 165Assert.Equal("Custom service", resourceEvent.Snapshot.ResourceTypeDisplayName); 172Assert.Equal("Updated service", resourceEvent.Snapshot.ResourceTypeDisplayName); 201Assert.Equal("Updated type", resourceEvent.Snapshot.ResourceType); 202Assert.Equal("CustomResource", resourceEvent.Snapshot.ResourceTypeDisplayName); 243Assert.Equal("CustomResource", c.Snapshot.ResourceType); 244Assert.Equal("value", c.Snapshot.Properties.Single(p => p.Name == "A").Value); 245Assert.Null(c.Snapshot.HealthStatus); 251Assert.Equal("CustomResource", c.Snapshot.ResourceType); 252Assert.Equal("value", c.Snapshot.Properties.Single(p => p.Name == "B").Value); 253Assert.Null(c.Snapshot.HealthStatus); 270Assert.Equal(HealthStatus.Unhealthy, resourceEvent.Snapshot.HealthStatus); 272resourceEvent.Snapshot.HealthReports, 323Assert.Equal("CustomResource", c.Snapshot.ResourceType); 324Assert.Equal("value", c.Snapshot.Properties.Single(p => p.Name == "A").Value); 330Assert.Equal("CustomResource", c.Snapshot.ResourceType); 331Assert.Equal("value", c.Snapshot.Properties.Single(p => p.Name == "B").Value); 337Assert.Equal("CustomResource", c.Snapshot.ResourceType); 338Assert.Equal("value", c.Snapshot.Properties.Single(p => p.Name == "C").Value); 529re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 533Assert.Equal(KnownResourceStates.Waiting, waitingEvent.Snapshot.State?.Text); 542re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 556Assert.DoesNotContain(completedWaitingEvent.Snapshot.Properties, p => p.Name == KnownProperties.Resource.WaitingFor); 633re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 637Assert.Equal(KnownResourceStates.Waiting, waitingEvent.Snapshot.State?.Text); 651re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 670Assert.DoesNotContain(completedWaitingEvent.Snapshot.Properties, p => p.Name == KnownProperties.Resource.WaitingFor); 689re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 693Assert.Equal(KnownResourceStates.Waiting, waitingEvent.Snapshot.State?.Text); 703re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 718Assert.DoesNotContain(completedWaitingEvent.Snapshot.Properties, p => p.Name == KnownProperties.Resource.WaitingFor); 743re => re.Snapshot.State?.Text == KnownResourceStates.Waiting, 746Assert.Equal(KnownResourceStates.Waiting, waitingEvent.Snapshot.State?.Text); 789Assert.Equal(state, resourceEvent.Snapshot.State?.Text); 823re => re.ResourceId == "resource-abc123" && re.Snapshot.State?.Text == KnownResourceStates.Waiting, 827Assert.Equal(KnownResourceStates.NotStarted, notStartedEvent.Snapshot.State?.Text); 837Assert.Equal(KnownResourceStates.NotStarted, notStartedEvent.Snapshot.State?.Text); 867Assert.Equal(KnownResourceStates.NotStarted, notStartedEvent.Snapshot.State?.Text); 894re => re.Snapshot.State?.Text == KnownResourceStates.Waiting, 933re => re.ResourceId == "resource-abc123" && re.Snapshot.State?.Text == KnownResourceStates.Waiting, 965re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 978re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 992Assert.DoesNotContain(completedWaitingEvent.Snapshot.Properties, p => p.Name == KnownProperties.Resource.WaitingFor); 1008Assert.Contains(waitingEvent.Snapshot.Properties, p => p.Name == KnownProperties.Resource.WaitingFor); 1016Assert.DoesNotContain(runningEvent.Snapshot.Properties, p => p.Name == KnownProperties.Resource.WaitingFor); 1069re => re.Snapshot.State?.Text == KnownResourceStates.Waiting && 1289Assert.Equal("ExistingIcon", firstEvent.Snapshot.IconName); 1290Assert.Equal(IconVariant.Filled, firstEvent.Snapshot.IconVariant); 1294Assert.Equal("ExistingIcon", secondEvent.Snapshot.IconName); 1295Assert.Equal(IconVariant.Filled, secondEvent.Snapshot.IconVariant); 1296Assert.Equal("Running", secondEvent.Snapshot.State?.Text); 1331Assert.Equal("LastIcon", value.Snapshot.IconName); 1332Assert.Equal(IconVariant.Regular, value.Snapshot.IconVariant); 1333Assert.Equal("Starting", value.Snapshot.State?.Text); 1367Assert.Equal("AnnotationIcon", value.Snapshot.IconName); 1368Assert.Equal(IconVariant.Regular, value.Snapshot.IconVariant); 1369Assert.Equal("Starting", value.Snapshot.State?.Text); 1511Assert.Equal(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Healthy, resourceEvent.Snapshot.HealthStatus); 1512Assert.NotNull(resourceEvent.Snapshot.ResourceReadyEvent); 1513Assert.True(resourceEvent.Snapshot.ResourceReadyEvent.EventTask.IsCompletedSuccessfully); 1579Assert.Equal(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Healthy, resourceEvent.Snapshot.HealthStatus); 1604Assert.Equal(HealthStatus.Healthy, resourceEvent.Snapshot.HealthStatus); 1605Assert.True(resourceEvent.Snapshot.ResourceReadyEvent?.EventTask.IsCompletedSuccessfully); 1626return resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running; 1636Assert.Equal(KnownResourceStates.Running, (await waitTask.DefaultTimeout()).Snapshot.State?.Text); 1669return resourceEvent.Snapshot.State?.Text == KnownResourceStates.Running; 1673Assert.Equal(KnownResourceStates.Running, (await waitTask).Snapshot.State?.Text); 1757Assert.True((await waitTask.DefaultTimeout()).Snapshot.ResourceReadyEvent?.EventTask.IsCompletedSuccessfully); 1776Assert.True((await waitTask.DefaultTimeout()).Snapshot.ResourceReadyEvent?.EventTask.IsCompletedSuccessfully); 1873return resourceEvent!.Snapshot.IsHidden; 1922Assert.Equal(initial.Snapshot.Version, unchanged.Snapshot.Version); 1927Assert.True(changed.Snapshot.Version > initial.Snapshot.Version, "A real change should publish a new version."); 1928Assert.Equal("SomeOtherState", changed.Snapshot.State?.Text); 1987Assert.Equal(initial.Snapshot.Version, unchanged.Snapshot.Version); 2000Assert.True(changed.Snapshot.Version > initial.Snapshot.Version, "A changed value inside a List<T> property should publish a new version."); 2019Assert.Equal(initial.Snapshot.Version, unchanged.Snapshot.Version); 2040changed.Snapshot.Version > initial.Snapshot.Version, 2072changed.Snapshot.Version > initial.Snapshot.Version, 2078var 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)) 617e => e.Snapshot.Urls.Length == 1).DefaultTimeout(); 621Assert.Single(resourceEvent.Snapshot.Urls, s => s.Name == httpEndpoint.EndpointName && s.IsInactive && s.Url == "https://example.com"); 642e => e.Snapshot.Urls.Length == 3).DefaultTimeout(); 646Assert.Collection(resourceEvent.Snapshot.Urls, 675e => e.Snapshot.State == KnownResourceStates.Running 676&& e.Snapshot.Urls.Length == 2 677&& e.Snapshot.Urls.All(url => !url.IsInactive)).DefaultTimeout(); 681Assert.Equal(2, resourceEvent.Snapshot.Urls.Length); 682Assert.Collection(resourceEvent.Snapshot.Urls, 708if (notification.Resource == servicea.Resource && notification.Snapshot.Urls.Length > 0) 710urlSnapshots.Add(notification.Snapshot.Urls.ToArray()); 711TestOutputHelper.WriteLine($"Captured snapshot #{urlSnapshots.Count}: State={notification.Snapshot.State}, URLs: {FormatUrls(notification.Snapshot.Urls)}"); 714if (notification.Snapshot.State == KnownResourceStates.Running && 715notification.Snapshot.Urls.All(u => !u.IsInactive)) 785e => e.Snapshot.State == KnownResourceStates.Running && e.Snapshot.Urls.Length == 4).DefaultTimeout(); 789Assert.Collection(resourceEvent.Snapshot.Urls, 1118e => e.Snapshot.State == KnownResourceStates.Running 1119&& e.Snapshot.Urls.Length == resourceB.Resource.GetEndpoints().ToArray().Length + 1 1120&& e.Snapshot.Urls.All(u => !u.IsInactive), 1132var crossResourceUrl = resourceEvent.Snapshot.Urls.FirstOrDefault(u => u.DisplayProperties.DisplayName == "API Docs"); 1170e => e.Snapshot.State == KnownResourceStates.Running, 1173var crossResourceUrl = resourceEvent.Snapshot.Urls.FirstOrDefault(u => u.DisplayProperties.DisplayName == "API Docs"); 1185e => e.Snapshot.Urls.FirstOrDefault(u => u.DisplayProperties.DisplayName == "API Docs") is { IsInactive: false }, 1194e => 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);