public Task WhenIValidateTheServiceManifestCalled(string manifestName) { ITenantStore store = ContainerBindings.GetServiceProvider(this.scenarioContext).GetRequiredService <ITenantStore>(); ServiceManifest manifest = this.scenarioContext.Get <ServiceManifest>(manifestName); return(CatchException.AndStoreInScenarioContextAsync( this.scenarioContext, () => manifest.ValidateAndThrowAsync(store))); }
/// <summary> /// Creates a new tenant representing a Marain service that tenants can enroll to use. /// </summary> /// <param name="tenantStore">The tenant store.</param> /// <param name="manifest"> /// The manifest for the service. The service name in the manifest must be unique across all service tenants. /// </param> /// <param name="logger">Optional logger.</param> /// <returns>The new tenant.</returns> public static async Task <ITenant> CreateServiceTenantAsync(this ITenantStore tenantStore, ServiceManifest manifest, ILogger?logger = null) { if (manifest == null) { throw new ArgumentNullException(nameof(manifest)); } logger?.LogDebug("Validating service manifest for service creation."); await manifest.ValidateAndThrowAsync(tenantStore).ConfigureAwait(false); ITenant parent = await tenantStore.GetServiceTenantParentAsync().ConfigureAwait(false); logger?.LogDebug( "Creating new service tenant '{serviceName}' with well-known GUID '{wellKnownGuid}'", manifest.ServiceName, manifest.WellKnownTenantGuid); ITenant newTenant = await tenantStore.CreateWellKnownChildTenantAsync( parent.Id, manifest.WellKnownTenantGuid, manifest.ServiceName).ConfigureAwait(false); logger?.LogDebug( "New service tenant '{serviceName}' created with Id '{tenantId}'; updating tenant type and manifest.", newTenant.Name, newTenant.Id); IEnumerable <KeyValuePair <string, object> > properties = PropertyBagValues.Build(p => p .AddServiceManifest(manifest) .AddMarainTenantType(MarainTenantType.Service)); await tenantStore.UpdateTenantAsync( newTenant.Id, propertiesToSetOrAdd : properties).ConfigureAwait(false); logger?.LogInformation( "Created new service tenant '{serviceName}' with Id '{tenantId}'.", newTenant.Name, newTenant.Id); return(newTenant); }