public void SetUp() { // TODO -- Pull this from the app config var clarify = ClarifyApplication.Initialize(new NameValueCollection { { "fchoice.connectionstring", "Data Source=.; Initial Catalog=mobilecl125; User Id=sa; Password=sa;" }, { "fchoice.dbtype", "mssql" }, { "fchoice.disableloginfromfcapp", "false" }, { "fchoice.sessionpasswordrequired", "false" }, { "fchoice.nocachefile", "true" } }); IClarifySessionUsageReporter reporter; theApplication = new InMemoryClarifyApplication(clarify); var logger = new NulloLogger(); Func <IUserSessionStartObserver> startObserver = () => { reporter = new ClarifySessionUsageReporter(theCache, theApplication, logger); return(new SessionStartObserver(reporter)); }; theCache = new ClarifySessionCache(theApplication, logger, new NulloSessionConfigurator(), () => new SessionEndObserver(), startObserver, new DovetailDatabaseSettings()); theData = new ObjectMother(clarify); theEmployee = theData.GenerateEmployees(1).Single(); theSessionId = theCache.GetSession(theEmployee).Id; theApplication.InvalidateSession(theSessionId); }
public void reserve_lots_of_licenses() { var mother = new ObjectMother(_cut.GetApplicationSession()); logSDKLicense(); var licLog = Enumerable.Range(0, 14).Select(index => { var session = _cut.GetSession(mother.CreateEmployee().Login); var lic = getSDKLicense(); return(new LicLog { Remaining = lic.UserLicensesRemaining, GraceRemaining = lic.GraceLicensesRemaining, GraceEventsRemaining = lic.GraceEventsRemaining, Session = session }); }).ToArray(); licLog.Each(r => Console.WriteLine(r.ToString())); foreach (var log in licLog) { _cut.EjectSession(log.Session.UserName); logSDKLicense(); } }
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); }
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); }