I have WCF service that I am trying to Unit Tests. The only dependency the service has is the call to OperationContext.Current.ServiceSecurityContext.WindowsIdentity.Name to know the windows user that uses that service (windows authentication) I want to mock only this. Someone has simple way to do it?
Depending on how your service is configured, Thread.CurrentPrincipal will likely contain a principal representing the connected client. So you could get the name from that rather than having a dependency on OperationContext.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.