コード例 #1
0
        public static User Register(IEventStoreSession aggregates, string email, string password, Guid id)
        {
            var user = new User();

            user.Register(email, password, id);
            aggregates.Save(user);
            return(user);
        }
コード例 #2
0
            public static MyAccount Register(IEventStoreSession aggregates, Guid accountId, string email, string password)
            {
                var registered = new MyAccount();

                registered.RaiseEvent(new AccountRegisteredEvent(accountId, email, password));
                aggregates.Save(registered);
                return(registered);
            }
コード例 #3
0
        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));
        }
コード例 #4
0
 public virtual void Add(TAggregate aggregate)
 {
     Aggregates.Save(aggregate);
 }