I have the class under test:
1.
public
class
AppManager {
2.
public
string
[] GetAppSets() => Registry.LocalMachine
3.
.OpenSubKey(@
"SOFTWARE\Autodesk\AutoCAD"
,
false
)
4.
?.GetSubKeyNames();
5.
}
Also, I have the test for `GetAppSets` method:
01.
[Test]
02.
public
void
Foo_Returns_ValidValue() {
03.
04.
const
string
subkey = @
"SOFTWARE\Autodesk\AutoCAD"
;
05.
/* The sets of applications which are based on
06.
* AutoCAD 2009-2017. */
07.
string
[] fakeSets =
new
[] {
"R17.2"
,
"R18.0"
,
08.
"R18.1"
,
"R18.2"
,
"R19.0"
,
"R19.1"
,
"R20.0"
,
09.
"R20.1"
,
"R21.0"
};
10.
11.
RegistryKey rk = Mock.Create<RegistryKey>();
12.
13.
Mock.Arrange(() => rk.GetSubKeyNames()).Returns(
14.
fakeSets);
15.
16.
Mock.Arrange(() => Registry.LocalMachine.OpenSubKey
17.
(subkey,
false
)).Returns(rk);
18.
19.
AppManager appMng =
new
AppManager();
20.
string
[] appSets = appMng.GetAppSets();
21.
22.
Assert.AreEqual(fakeSets, appSets);
23.
}
It works. But my test will be failure if `GetAppSets` method uses "Software\Autodesk\AutoCAD" or "software\autodesk\autocad" string instead of "SOFTWARE\Autodesk\AutoCAD".
So, at this case I need to handle parameter like the case insensitive string. Is it possible?