Open johlju opened 5 years ago
I don't think this one can be resolved? I thought I share my findings if someone else stumbles on the same problem, or if there are someone that can figure out a clever solution (other than manually change the code after the fact). 🙂
The stub cmdlet
Move-ADDirectoryServer
passes a string in the parameterSite
. But the parameterSite
is of the typeMicrosoft.ActiveDirectory.Management.ADReplicationSite
which is a stub type. When using an assert like below, theToString()
method does not return anything, neither does$Site.Name
which is a property of the typeMicrosoft.ActiveDirectory.Management.ADReplicationSite
.Example of assert that fails.
The stub cmdlet looks like this.
The stub type ADReplicationSite looks like this.
So the above assert failed because
ToString()
does not exist in the stub type, and$Site.Name does not contain the string value passed to the parameter
Site, of the cmdlet Move-ADDirectoryServer, because there are no logic in the stub class
ADReplicationSite` to handle that.If I add logic to the class
ADReplicationSite
constructor that takes a string as argument, and change the test code to assert on$Site.Name
then the assert works. I could have added theToString()
method to return theSite.Name
property, but that is more uncertain if that is what the realToString()
method does.Changed logic in the class
ADReplicationSite
. Just showing the relevant parts.Changed logic in the assert in the test.