public void CreateReadOnlyRepository_Throws_Exception()
 {
     using (IDbSession dbSession = _dbSessionFactory.Create())
     {
         dbSession.CreateReadOnlyRepository <Person>();
     }
 }
        public void Create_Returns_Db_Session()
        {
            DbSessionFactory dbSessionFactory = new DbSessionFactory(Helpers.ConnectionString);

            IDbSession dbSession = dbSessionFactory.Create();

            Assert.IsNotNull(dbSession);
        }
        public void Create_Returns_Db_Session()
        {
            InMemoryDb       db = new InMemoryDb();
            DbSessionFactory dbSessionFactory = new DbSessionFactory(db);

            IDbSession dbSession = dbSessionFactory.Create();

            Assert.IsNotNull(dbSession);
        }
Ejemplo n.º 4
0
        public void Create_Returns_Db_Session()
        {
            DbSessionFactory dbSessionFactory = new DbSessionFactory(Helpers.ConnectionString, Helpers.ResourceAssembly);

            using (IDbSession dbSession = dbSessionFactory.Create())
            {
                Assert.IsNotNull(dbSession);
            }
        }
Ejemplo n.º 5
0
        public void Create_Adds_Entities_To_The_Table()
        {
            int       currentCount;
            const int numToAdd = 3;

            using (IDbSession dbSession = _dbSessionFactory.Create())
            {
                IKeyedRepository <Guid, Person> repo = dbSession.CreateKeyedRepository <Guid, Person>();

                // create
                currentCount = repo.All().Count();
                for (int i = 0; i < numToAdd; i++)
                {
                    Assert.IsTrue(repo.Add(CreatePerson()));
                }

                dbSession.Commit();
            }
            using (IDbSession dbSession = _dbSessionFactory.Create())
            {
                IKeyedRepository <Guid, Person> repo = dbSession.CreateKeyedRepository <Guid, Person>();
                int newCount = repo.All().Count();

                Assert.IsTrue(currentCount + numToAdd == newCount);
            }
        }
Ejemplo n.º 6
0
        public void Create_Adds_Entities_To_The_Table()
        {
            using (IDbSession dbSession = _dbSessionFactory.Create())
            {
                IKeyedRepository <int, Person> repo = dbSession.CreateKeyedRepository <int, Person>();

                // create
                int expectedCount = repo.All().Count();
                for (int i = 0; i < 3; i++)
                {
                    Assert.IsTrue(repo.All().Count() == expectedCount++);
                    Assert.IsTrue(repo.Add(CreatePerson()));
                    Assert.IsTrue(repo.All().Count() == expectedCount);
                }

                dbSession.Commit();
            }
        }