public void ShouldCacheEventsBetweenInstancesTransaction()
        {
            string connectionString = ConfigurationManager.ConnectionStrings["EventStore"].ConnectionString;

            var something = new SqlServerEventStore(connectionString);

            var user = new User();
            user.Register("*****@*****.**", "password", Guid.NewGuid());
            var stored = (IEventStored) user;

            using (var tran = new TransactionScope())
            {
                something.SaveEvents(stored.GetChanges());
                something.GetAggregateHistory(user.Id);
                Assert.That(something.GetAggregateHistory(user.Id), Is.Not.Empty);
                tran.Complete();
            }

            something = new SqlServerEventStore(connectionString);
            var firstRead = something.GetAggregateHistory(user.Id).Single();

            something = new SqlServerEventStore(connectionString);
            var secondRead = something.GetAggregateHistory(user.Id).Single();

            Assert.That(firstRead, Is.SameAs(secondRead));
        }
        public void ShouldNotCacheEventsSavedDuringFailedTransactionEvenIfReadDuringSameTransaction()
        {
            var something = new SqlServerEventStore(ConfigurationManager.ConnectionStrings["EventStore"].ConnectionString);
            something.ResetDB();//Sometimes the test would fail on the last line with information that the table was missing. Probably because the table was created during the aborted transaction. I'm hoping this will fix it.

            var user = new User();
            user.Register("*****@*****.**", "password", Guid.NewGuid());

            using (new TransactionScope())
            {
                something.SaveEvents(((IEventStored) user).GetChanges());
                something.GetAggregateHistory(user.Id);
                Assert.That(something.GetAggregateHistory(user.Id), Is.Not.Empty);
            }

            Assert.That(something.GetAggregateHistory(user.Id), Is.Empty);
        }
 public static void ResetDB(string connectionString)
 {
     using (var session = new SqlServerEventStore(connectionString))
     {
         session.ResetDB();
     }
 }
 public void Does_not_call_db_in_constructor()
 {
     var eventStore = new SqlServerEventStore("SomeStringThatDoesNotPointToARealSqlServer");
 }