Beispiel #1
0
        public async Task Handle(TargetDisabled notification, CancellationToken cancellationToken)
        {
            if (!_configurationInstanceHolder.TryGet(notification.TargetId,
                                                     out DeploymentTargetWorker? worker))
            {
                _logger.Warning("Could not get worker for target id {TargetId}", notification.TargetId);
                return;
            }

            await StopWorkerAsync(worker, cancellationToken);
        }
Beispiel #2
0
        public void WhenRegisteringSingleInstanceTryGet()
        {
            var holder   = new ConfigurationInstanceHolder();
            var instance = new ValidatableOptional("abc", 123);

            holder.Add(new NamedInstance <ValidatableOptional>(instance, "abc-instance"));

            bool found = holder.TryGet("abc-instance", out ValidatableOptional? foundInstance);

            Assert.True(found);
            Assert.Same(instance, foundInstance);
        }
Beispiel #3
0
        public void WhenRemovingNonExistingType()
        {
            var holder = new ConfigurationInstanceHolder();

            holder.Add(new NamedInstance <ValidatableOptional>(new ValidatableOptional("abc", 123), "abc-instance"));

            bool found = holder.TryGet("abc-instance", out ValidatableOptional? instance);

            Assert.True(found);

            Assert.NotNull(instance);

            bool isRemoved = holder.TryRemove("abc-instance", typeof(string), out object?removed);

            Assert.False(isRemoved);

            Assert.Null(removed);
        }