Beispiel #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.");
        }
Beispiel #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);
        }