The foillowing test is successful when I run it with Visual Studio Testrunner but fails when I run it with SmartRunner even if I do not mocking at all. I just use the TypeMock Testrunner. That's all.
[TestMethod]
[TestCategory("IntegrationTest")]
public void ATest()
{
// I know that is not a test that makes any sense. It's just some code
// to illustrate the issue that I have with SmartRunner.
using (new Impersonator(new NetworkCredential("username", "password", "domain.local")))
{
using (DirectoryEntry de = new DirectoryEntry("LDAP://domain.local"))
{
SearchResult adSearchResult = null;
using (DirectorySearcher adSearch = new DirectorySearcher(de))
{
adSearch.Filter = string.Format("(sAMAccountName={0})", "MockTestUser");
adSearchResult = adSearch.FindOne();
}
}
}
}
The Impersonator is using native method LogonUser from advapi32.dll to perform the impersonation.
Result with VS Testrunner:

Result with SmartRunner:

So question is why does this "test" fail when i use it with SmartRunner. Is there something I can do to get it running?