Esempio n. 1
0
        public void can_run_all_actions_in_parallel()
        {
            for (var i = 0; i < 1500; i++)
            {
                Parallel.Invoke(
                    () => theCache.CleanUpInvalidSessions(),
                    () => theCache.GetSession(theEmployee).As <ClarifySessionWrapper>().ClarifySession.SessionData.ShouldNotBeNull(),
                    () => theCache.CleanUpInvalidSessions(),
                    () => useSession(),
                    () => theApplication.InvalidateSession(theSessionId),
                    () => useSession()
                    );

                theApplication.InvalidateSession(theSessionId);

                Thread.Sleep(100);
            }

            var sessions        = theCache.SessionsByUsername.Values;
            var invalidSessions = sessions.Where(_ => !theApplication.IsSessionValid(_.Id)).ToArray();

            invalidSessions.Length.ShouldEqual(0);
        }
Esempio n. 2
0
        public void can_run_all_actions_in_parallel()
        {
            Parallel.Invoke(
                () => theCache.GetSession("sa"),
                () => theCache.GetSession(theInactiveEmployees[0]),
                () => theCache.GetSession(theInactiveEmployees[0]),
                () => theCache.GetSession(theInactiveEmployees[1]),
                () => theCache.CleanUpInvalidSessions(),
                () => theCache.GetSession(theOtherEmployees[0]),
                () => theCache.GetSession(theOtherEmployees[1]),
                () => theCache.GetSession(theOtherEmployees[2]),
                () => theCache.GetSession(theOtherEmployees[3]),
                () => theCache.GetSession(theOtherEmployees[4])
                );

            var sessions        = theCache.SessionsByUsername.Values;
            var invalidSessions = sessions.Where(_ => !theApplication.IsSessionValid(_.Id)).ToArray();

            invalidSessions.Length.ShouldEqual(0);
        }