You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The stub cmdlet Move-ADDirectoryServer passes a string in the parameter Site. But the parameter Site is of the type Microsoft.ActiveDirectory.Management.ADReplicationSite which is a stub type.
When using an assert like below, the ToString() method does not return anything, neither does $Site.Name which is a property of the type Microsoft.ActiveDirectory.Management.ADReplicationSite.
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 the ToString() method to return the Site.Name property, but that is more uncertain if that is what the real ToString() method does.
Changed logic in the class ADReplicationSite. Just showing the relevant parts.
publicclass ADReplicationSite
{// Constructor
...public ADReplicationSite(System.String identity){this.Name =identity;}
...// Property
...
public System.String Name {get;set;}
...}
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, the
ToString()
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.
The text was updated successfully, but these errors were encountered: