在单元测试中设置Windows标识 [英] Setting the windows identity in a unit test

查看:79
本文介绍了在单元测试中设置Windows标识的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



有人可以指点我一篇文章或者告诉我如何在我的单元测试中设置windows身份。我正在测试一些需要获取windows主体的代码但是当我使用VSTS测试它时,Thread.CurrentPrincipal已经设置为通用主体。我似乎找到了关于如何控制这个的任何文档,所以任何帮助赞赏。 (我已经尝试在代码中设置app域主体策略无效 - 我认为它已经被单元测试框架代码设置为通用主体了吗?)。



Adrian



http://www.adriancolquhoun.com

解决方案

嗨Adrian,

试试这个







Wi ndowsIdentity.GetCurrent();

Hi

Could someone point me to an article or advise me how to set the windows identity in my unit tests. I am testing some code that needs to grab the windows principal but when I test it using VSTS the Thread.CurrentPrincipal is already set to a generic principal. I could seem to find any documentation on how to control this so any help appreciated. (I've tried setting the app domain principal policy in code to no effect - I think it has already been set to generic principal by the unit test framework code?).

Thanks

Adrian 


http://www.adriancolquhoun.com

解决方案

Hi Adrian,

Try this

WindowsIdentity.GetCurrent(); 


这篇关于在单元测试中设置Windows标识的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆