Ejemplo n.º 1
0
        public void Should_Return_Anonymous_Principal_Name()
        {
            var origPrincipal = Thread.CurrentPrincipal;

            Thread.CurrentPrincipal = null;

            var principalProvider = new DefaultPrincipalProvider();
            var name = principalProvider.CurrentPrincipalName;

            Assert.AreEqual(name, DefaultPrincipalProvider.AnonymousPrincipalName);

            Thread.CurrentPrincipal = origPrincipal;
        }
Ejemplo n.º 2
0
        public void Should_Return_CurrectPrincipal_Name()
        {
            var origPrincipal = Thread.CurrentPrincipal;
            var principal     = new GenericPrincipal(new GenericIdentity("TestPrincipal2"), null);

            Thread.CurrentPrincipal = principal;

            var principalProvider = new DefaultPrincipalProvider();
            var name = principalProvider.CurrentPrincipalName;

            Assert.AreEqual(name, "TestPrincipal2");

            Thread.CurrentPrincipal = origPrincipal;
        }
Ejemplo n.º 3
0
        public void Should_Return_CurrectPrincipal()
        {
            var origPrincipal = Thread.CurrentPrincipal;
            var principal     = new GenericPrincipal(new GenericIdentity("TestPrincipal1"), null);

            Thread.CurrentPrincipal = principal;

            var principalProvider  = new DefaultPrincipalProvider();
            var retrievedPrincipal = principalProvider.GetCurrentPrincipal();

            Assert.AreEqual(principal, retrievedPrincipal);

            Thread.CurrentPrincipal = origPrincipal;
        }