コード例 #1
0
        public void LoginThenLogout()
        {
            AuthenticationService1 context = new AuthenticationService1(TestURIs.AuthenticationService1);
            FormsAuthentication service = new FormsAuthentication();

            service.DomainContext = context;

            AuthenticationOperation ao = service.Login("manager", "manager");

            this.EnqueueConditional(() => ao.IsComplete);

            this.EnqueueCallback(() =>
            {
                Assert.IsTrue(ao.User.Identity.IsAuthenticated,
                    "Logged in user should be authenticated.");
                ao = service.Logout(false);
            });

            this.EnqueueConditional(() => ao.IsComplete);

            this.EnqueueCallback(() =>
            {
                Assert.IsFalse(ao.User.Identity.IsAuthenticated,
                    "Logged out user should not be authenticated.");
                ao = service.Logout(false);
            });

            this.EnqueueTestComplete();
        }
コード例 #2
0
        public void Defaults()
        {
            AuthenticationService1 context = new AuthenticationService1(TestURIs.AuthenticationService1);
            FormsAuthentication service = new FormsAuthentication();

            service.DomainContext = context;
            Assert.IsNotNull(service.User,
                "User should not be null.");
            Assert.IsNotNull(service.User.Identity,
                "Identity should not be null.");
            Assert.IsNotNull(service.User.Identity.AuthenticationType,
                "Authentication type should not be null.");
            Assert.IsFalse(service.User.Identity.IsAuthenticated,
                "Authentication state should be false.");
            Assert.IsNotNull(service.User.Identity.Name,
                "Name should not be null.");

            Assert.IsFalse(service.User.IsInRole("Role"),
                "This method should not throw.");
        }