CQRS.Tests.CQRS.EventSourcing.Sql.SqlServerEventStoreTest.ShouldNotCacheEventsSavedDuringFailedTransactionEvenIfReadDuringSameTransaction C# (CSharp) Method

ShouldNotCacheEventsSavedDuringFailedTransactionEvenIfReadDuringSameTransaction() private method

        public void ShouldNotCacheEventsSavedDuringFailedTransactionEvenIfReadDuringSameTransaction()
        {
            using(var dbManager = new TemporaryLocalDbManager(ConfigurationManager.ConnectionStrings["MasterDb"].ConnectionString))
            {
                var connectionString = dbManager.CreateOrGetLocalDb("SqlServerEventStoreTest_EventStore1");
                var something = new SqlServerEventStore(connectionString, new SingleThreadUseGuard());
                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("[email protected]", "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);
            }
        }