私は私のユニットテストで使用する必要があるWindowsレジストリを模擬したいC#を使用します。 私はHKLMとHKCUのレジストリを設定する関数を書いています。以下の関数のユニットテストを書くにはどうすればいいですか?私はこのWindowsレジストリ操作のユニットテスト
public static bool createHkcuRegistry(string registryPath, string valueName, string value, RegistryValueKind valueKind = RegistryValueKind.String)
{
try
{
RegistryKey key = Registry.CurrentUser.OpenSubKey(registryPath, true);
if (key != null)
{
key.SetValue(valueName, value, valueKind);
key.Close();
}
else
{
RegistryKey newKey = Registry.CurrentUser.CreateSubKey(registryPath);
newKey.SetValue(valueName, value, valueKind);
}
return true;
}
}
なぜあなたは 'systemWrapper'を望んでいませんか? –
SystemWrapperを使用したくない場合は、抽象レジストリのアクセスを介して、この要件を解決する最善の方法として抽象化を再作成することができます – Nkosi
私は実際のレジストリを偽装する必要があります。 – VJL