//// ===========================================================================================================
        //// Methods
        //// ===========================================================================================================

        /// <summary>
        /// Reads a value from the Windows registryKey.
        /// </summary>
        /// <typeparam name="T">The type of value that is read (<see cref="RegistryReadValueCommand{T}"/>).</typeparam>
        /// <param name="command">The command to execute.</param>
        /// <param name="logger">The logger to use.</param>
        /// <returns>A response indicating success and the read value, or failure with error details.</returns>
        public IServiceCommandResponse ExecuteRead <T>(RegistryReadValueCommand <T> command, ILogger logger)
        {
            Param.VerifyNotNull(command, nameof(command));
            Param.VerifyNotNull(logger, nameof(logger));

            ServiceCommandResponse response;

            try
            {
                var registryHive = (RegistryHive)Enum.Parse(typeof(RegistryHive), command.BaseKey.ToString());

                using (IWin32RegistryKey baseKey = _registry.OpenBaseKey(registryHive, RegistryView.Registry64))
                    using (IWin32RegistryKey subKey = baseKey.OpenSubKey(command.Key, writable: false))
                    {
                        object value = subKey?.GetValue(command.ValueName, command.DefaultValue) ?? command.DefaultValue;
                        response = ServiceCommandResponse.Create(command.CommandName, value);
                    }
            }
            catch (Exception e)
            {
                response = ServiceCommandResponse.CreateError(
                    command.CommandName,
                    ServiceErrorInfo.RegistryReadError(
                        RegistryPath.HiveToWin32Name(RegistryPath.BaseKeyToHive(command.BaseKey)),
                        command.Key,
                        command.ValueName,
                        e));
                logger.LogError(response.ErrorMessage);
            }

            return(response);
        }
        public void GetValue_should_return_the_default_value_if_not_present()
        {
            var registry = new FakeRegistry();

            using (IWin32RegistryKey hkcu = registry.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry64))
                using (IWin32RegistryKey subKey = hkcu.CreateSubKey("SubKey"))
                {
                    subKey.GetValue("NoValue", 100).Should().Be(100);
                }
        }
        public void SetValue_should_create_the_value_if_not_present()
        {
            var registry = new FakeRegistry();

            using (IWin32RegistryKey hkcu = registry.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry64))
                using (IWin32RegistryKey subKey = hkcu.CreateSubKey("SubKey", writable: true))
                {
                    subKey.SetValue("ValueName", 123, RegistryValueKind.DWord);
                    subKey.GetValue("ValueName").Should().Be(123);
                }
        }