public void TestInitializer()
        {
            SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
            builder.DataSource = @".\SQLEXPRESS";
            builder.IntegratedSecurity = true;
            builder.InitialCatalog = "DBBlogs";
            SqlConnection connection1 = new SqlConnection(builder.ConnectionString);
            connection1.Open();
            _currentTransaction1 = connection1.BeginTransaction();
            SqlConnection connection2 = new SqlConnection(builder.ConnectionString);
            connection2.Open();
            _currentTransaction2 = connection2.BeginTransaction();

            MetaDataStore metaDataStore = new MetaDataStore();
            metaDataStore.BuildTableInfoFor<Blog>();

            var identityMap1 = new IdentityMap();
            var identityMap2 = new IdentityMap();

            _blogMapper1 = new BlogMapper(connection1,
                _currentTransaction1,
                metaDataStore,
                new EntityHydrater(metaDataStore, identityMap1),
                identityMap1);
            _blogMapper2 = new BlogMapper(connection2,
                _currentTransaction2,
                metaDataStore,
                new EntityHydrater(metaDataStore, identityMap2),
                identityMap2);
        }
        public void Can_Create_Blog_With_Mapper()
        {
            var connectionString = ConfigurationManager.ConnectionStrings[ConnectionStringName].ConnectionString;
            using (var connection = new SqlConnection(connectionString))
            { 
                connection.Open();
                using (var transaction = connection.BeginTransaction())
                { 
                    var metaDataStore = new MetaDataStore();
                    metaDataStore.BuildTableInfoFor<Blog>();
                    var identityMap = new IdentityMap();
                    var hydrater = new EntityHydrater(metaDataStore, identityMap);
                    BlogMapper blogMapper = new BlogMapper(connection, transaction, metaDataStore, hydrater, identityMap);

                    Blog blog = new Blog { Name = "PROMPT", Description = "Módulo 5 - Plataformas e modelos de acesso a dados" };
                    blog = blogMapper.Insert(blog);

                    Assert.IsNotNull(blog);
                    Assert.IsTrue(blog.Id > 0);
                    Assert.AreEqual("PROMPT", blog.Name);
                    Assert.AreEqual("Módulo 5 - Plataformas e modelos de acesso a dados", blog.Description);

                    transaction.Commit();
                }
            }
        }
        public void Can_FindAll_Blogs_With_Mapper()
        {
            // Prepare
            var connectionString = ConfigurationManager.ConnectionStrings[ConnectionStringName].ConnectionString;
            using (var connection = new SqlConnection(connectionString))
            { 
                connection.Open();
                using (var transaction = connection.BeginTransaction())
                { 
                    var metaDataStore = new MetaDataStore();
                    metaDataStore.BuildTableInfoFor<Blog>();
                    var identityMap = new IdentityMap();
                    var hydrater = new EntityHydrater(metaDataStore, identityMap);
                    BlogMapper blogMapper = new BlogMapper(connection, transaction, metaDataStore, hydrater, identityMap);

                    for (int i = 0; i < 10; i++)
                    {
                        Blog blog = new Blog { Name = "PROMPT " + i, Description = "Módulo " + i + " - Plataformas e modelos de acesso a dados" };
                        blogMapper.Insert(blog);
                    }
                    transaction.Commit();
                }
            }

            // Test with whole new references
            using (var connection = new SqlConnection(connectionString))
            { 
                connection.Open();
                using (var transaction = connection.BeginTransaction())
                { 
                    var metaDataStore = new MetaDataStore();
                    metaDataStore.BuildTableInfoFor<Blog>();
                    var identityMap = new IdentityMap();
                    var hydrater = new EntityHydrater(metaDataStore, identityMap);
                    BlogMapper blogMapper = new BlogMapper(connection, transaction, metaDataStore, hydrater, identityMap);
                    
                    var allBlogs = blogMapper.FindAll();
                    
                    Assert.AreEqual(10, allBlogs.Count());
                    for (int i = 0; i < 10; i++)
                    {
                        int blogi = i;
                        var blog = allBlogs.SingleOrDefault(b => b.Name == "PROMPT " + blogi);
                        Assert.IsNotNull(blog);
                    }

                    transaction.Commit();
                }
            }
        }