public bool UpdateService(string serviceFullName, bool runnerDisabled, IEnumerable <RequirementLayer> layers, IPluginDiscoverer d) { Debug.Assert(RunningError == null, "A service can not be in running error."); SolvedConfigStatus s; Info = d.FindService(serviceFullName); bool isAvailable = !(Info == null || Info.HasError); if (isAvailable) { if (runnerDisabled) { s = SolvedConfigStatus.Disabled; } else { s = SolvedConfigStatus.Optional; foreach (RequirementLayer l in layers) { ServiceRequirement r = l.ServiceRequirements.Find(serviceFullName); if (r != null && (int)r.Requirement > (int)s) { s = (SolvedConfigStatus)r.Requirement; } } } } else { s = SolvedConfigStatus.Disabled; } return(DoUpdateStatus(isAvailable, s)); }
void ServiceRequirementCollectionEvents(ServiceRequirementCollection collection) { string id = "service.full.name"; ServiceRequirementCollectionChangingEventArgs lastChanging = null; ServiceRequirementCollectionChangedEventArgs lastChanged = null; int changingCount = 0; int changedCount = 0; collection.Changing += (o, e) => { lastChanging = e; changingCount++; }; collection.Changed += (o, e) => { lastChanged = e; changedCount++; }; // Check add ServiceRequirement req = collection.AddOrSet(id, RunningRequirement.MustExistAndRun); Assert.That(changedCount == 1 && changingCount == 1); Assert.That(lastChanging.Action == CK.Core.ChangeStatus.Add); Assert.That(lastChanged.Action == CK.Core.ChangeStatus.Add); Assert.That(lastChanging.Collection == collection); Assert.That(lastChanged.Collection == collection); Assert.That(lastChanging.AssemblyQualifiedName == id); Assert.That(lastChanged.AssemblyQualifiedName == id); Assert.That(lastChanging.Requirement == RunningRequirement.MustExistAndRun); Assert.That(lastChanged.Requirement == RunningRequirement.MustExistAndRun); changedCount = 0; changingCount = 0; // Check delete : from the collection collection.Remove(id); Assert.That(changedCount == 1 && changingCount == 1); Assert.That(lastChanging.Action == CK.Core.ChangeStatus.Delete); Assert.That(lastChanged.Action == CK.Core.ChangeStatus.Delete); Assert.That(lastChanging.Collection == collection); Assert.That(lastChanged.Collection == collection); Assert.That(lastChanging.AssemblyQualifiedName == id); Assert.That(lastChanged.AssemblyQualifiedName == id); Assert.That(lastChanging.Requirement == RunningRequirement.MustExistAndRun); Assert.That(lastChanged.Requirement == RunningRequirement.MustExistAndRun); changedCount = 0; changingCount = 0; // Check clear collection.Clear(); Assert.That(changedCount == 1 && changingCount == 1); Assert.That(lastChanging.Action == CK.Core.ChangeStatus.ContainerClear); Assert.That(lastChanged.Action == CK.Core.ChangeStatus.ContainerClear); Assert.That(lastChanging.Collection == collection); Assert.That(lastChanged.Collection == collection); Assert.That(lastChanging.AssemblyQualifiedName == string.Empty); Assert.That(lastChanged.AssemblyQualifiedName == string.Empty); Assert.That(lastChanging.Requirement == 0); Assert.That(lastChanged.Requirement == 0); }
private void CheckTranslations(ServiceRequirement source, VmOpenApiLanguageItem target) { target.Value.Should().NotBeNull(); }
private void CheckTranslations(VmOpenApiLanguageItem source, ServiceRequirement target) { target.Requirement.Should().NotBeNull(); target.Localization.Code.Should().Be(source.Language); }