Example #1
0
        public void CreateUser()
        {
            MockUser           mockUser = MockUser.CreateDefaultUser();
            MockAuthentication provider = new MockAuthentication();

            AuthenticationBaseTest.SetUserInProviders(mockUser);

            // GetUser(IIdentity)
            MockUser userGUM = provider.GetAuthenticatedUserMock(mockUser);

            Assert.IsTrue(provider.WasCreateUserInvoked,
                          "CreateUser should have been invoked from GetUser(IIdentity).");

            provider.WasCreateUserInvoked = false;

            // GetAnonymousUser
            MockUser userGAU = provider.GetAnonymousUserMock();

            Assert.IsTrue(provider.WasCreateUserInvoked,
                          "GetAnonymousUser should have been invoked from GetUser.");

            provider.WasGetAnonymousUserInvoked = false;

            Assert.IsNotNull(provider.CreateUserMock(),
                             "User should not be null.");
        }
Example #2
0
        public void GetAnonymousUser()
        {
            MockUser           mockUser = MockUser.CreateDefaultUser();
            MockAuthentication provider = new MockAuthentication();

            AuthenticationBaseTest.SetUserInProviders(mockUser);

            // Logout
            MockUser userL = provider.Logout();

            Assert.IsTrue(provider.WasGetAnonymousUserInvoked,
                          "GetAnonymousUser should have been invoked from Logout.");

            provider.WasGetAnonymousUserInvoked = false;

            // GetUser
            MockUser userGU = provider.GetUser();

            Assert.IsTrue(provider.WasGetAnonymousUserInvoked,
                          "GetAnonymousUser should have been invoked from GetUser.");

            provider.WasGetAnonymousUserInvoked = false;

            // Logout should return the same value as GetAnonymousUser
            AuthenticationBaseTest.CompareUsers(mockUser, provider.GetAnonymousUserMock(), true);
            AuthenticationBaseTest.CompareUsers(mockUser, userL, true);
            AuthenticationBaseTest.CompareUsers(mockUser, userGU, true);
        }
Example #3
0
        public void UpdateUserThrows()
        {
            MockUser           original = MockUser.CreateDefaultUser();
            MockUser           user     = MockUser.CreateInitializedUser();
            MockAuthentication provider =
                ServerTestHelper.CreateInitializedDomainService <MockAuthentication>(DomainOperationType.Submit);

            ExceptionHelper.ExpectException <UnauthorizedAccessException>(
                () => provider.UpdateUser(user));
        }
Example #4
0
        public void Logout()
        {
            MockUser           mockUser = MockUser.CreateDefaultUser();
            MockAuthentication provider = new MockAuthentication();

            AuthenticationBaseTest.SetUserInProviders(mockUser);
            MockUser user = provider.Logout();

            AuthenticationBaseTest.CompareUsers(mockUser, user, true);
        }
Example #5
0
        public void UpdateUser()
        {
            MockUser           original = MockUser.CreateDefaultUser();
            MockUser           user     = MockUser.CreateInitializedUser();
            MockAuthentication provider = new MockAuthentication();

            AuthenticationBaseTest.SetUserInProviders(original);
            provider.UpdateUser(user);

            AuthenticationBaseTest.CompareUsers(user, original, false);
        }
Example #6
0
        public void ClearAuthenticationToken()
        {
            MockUser           mockUser = MockUser.CreateDefaultUser();
            MockAuthentication provider = new MockAuthentication();

            // Failure
            AuthenticationBaseTest.SetUserInProviders(null);
            MockUser user = provider.Logout();

            Assert.IsTrue(provider.WasClearAuthenticationTokenInvoked,
                          "ClearAuthenticationToken should have been invoked from Logout.");
        }
Example #7
0
        public void UpdateUserCore()
        {
            MockUser           original = MockUser.CreateDefaultUser();
            MockUser           user     = MockUser.CreateInitializedUser();
            MockAuthentication provider = new MockAuthentication();

            AuthenticationBaseTest.SetUserInProviders(original);
            provider.UpdateUserCoreMock(user);

            AuthenticationBaseTest.CompareUsers(user, original, false);

            // These tests are only valid when we can call SetUser directly
            //MockUser originalUU = MockUser.CreateDefaultUser();

            //AspNetUserDomainServiceTest.SetUserInProviders(originalUU);
            //provider.UpdateUser(user, originalUU);

            //Assert.IsTrue(provider.WasUpdateUserCoreInvoked,
            //    "UpdateUserCore should have been invoked from UpdateUser.");

            //AspNetUserDomainServiceTest.CompareUsers(original, originalUU, false);
        }