public void TryUpdateEnvironmentPropertiesAsync_should_return_false_and_do_not_create_non_existent_environment()
        {
            const string environment = "environment";

            var updatedProperties = new Dictionary <string, string>()
            {
                ["updatedKey"] = "updatedValue"
            };

            IEnvironmentInfoProperties UpdatePropertiesFunc(IEnvironmentInfoProperties props)
            {
                foreach (var property in updatedProperties)
                {
                    props.Set(property.Key, property.Value);
                }
                return(props);
            }

            var serviceDiscoveryManager = new ServiceDiscoveryManager(GetZooKeeperClient(), log: Log);

            serviceDiscoveryManager.TryUpdateEnvironmentPropertiesAsync(environment, UpdatePropertiesFunc)
            .GetAwaiter()
            .GetResult()
            .Should()
            .BeFalse();

            serviceDiscoveryManager.GetEnvironmentAsync(environment)
            .GetAwaiter()
            .GetResult()
            .Should()
            .BeNull();
        }
        public void TryUpdateEnvironmentPropertiesAsync_should_return_true_and_set_new_properties_for_existent_environment()
        {
            var initProperties = GetProperties();
            var environment    = "environment";

            CreateEnvironmentNode(environment, properties: initProperties);
            var updatedProperties = new Dictionary <string, string>()
            {
                ["updatedKey"] = "updatedValue"
            };

            IEnvironmentInfoProperties UpdatePropertiesFunc(IEnvironmentInfoProperties props)
            {
                foreach (var property in updatedProperties)
                {
                    props = props.Set(property.Key, property.Value);
                }
                return(props);
            }

            var serviceDiscoveryManager = new ServiceDiscoveryManager(GetZooKeeperClient(), log: Log);

            serviceDiscoveryManager.GetEnvironmentAsync(environment)
            .GetAwaiter()
            .GetResult()
            .Properties
            .Should()
            .BeEquivalentTo(initProperties);

            serviceDiscoveryManager.TryUpdateEnvironmentPropertiesAsync(environment, UpdatePropertiesFunc)
            .GetAwaiter()
            .GetResult()
            .Should()
            .BeTrue();

            serviceDiscoveryManager.GetEnvironmentAsync(environment)
            .GetAwaiter()
            .GetResult()
            .Properties
            .Should()
            .BeEquivalentTo(initProperties.Concat(updatedProperties));
        }