public static void CurrentPrincipal_SetNull() { // We run test on remote process because we need to set same principal policy // On netfx default principal policy is PrincipalPolicy.UnauthenticatedPrincipal DummyClass.RemoteInvoke(() => { AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.NoPrincipal); Assert.Null(Thread.CurrentPrincipal); Thread.CurrentPrincipal = null; Assert.Null(Thread.CurrentPrincipal); Thread.CurrentPrincipal = new ClaimsPrincipal(); Assert.IsType <ClaimsPrincipal>(Thread.CurrentPrincipal); Thread.CurrentPrincipal = null; Assert.Null(Thread.CurrentPrincipal); Thread.CurrentPrincipal = new ClaimsPrincipal(); Assert.IsType <ClaimsPrincipal>(Thread.CurrentPrincipal); }).Dispose(); }