public void ThrowsIfUsedByMultipleThreads() { var store = CreateStore(); IEventStoreSession session = null; var wait = new ManualResetEventSlim(); ThreadPool.QueueUserWorkItem((state) => { session = OpenSession(store); wait.Set(); }); wait.Wait(); User user; Assert.Throws <MultiThreadedUseException>(() => session.Get <User>(Guid.NewGuid())); Assert.Throws <MultiThreadedUseException>(() => session.Dispose()); Assert.Throws <MultiThreadedUseException>(() => session.LoadSpecificVersion <User>(Guid.NewGuid(), 1)); Assert.Throws <MultiThreadedUseException>(() => session.Save(new User())); Assert.Throws <MultiThreadedUseException>(() => session.SaveChanges()); Assert.Throws <MultiThreadedUseException>(() => session.TryGet(Guid.NewGuid(), out user)); }
public void Dispose() { _session.Dispose(); _session = null; }