public void QueriesForAllElementsOfTypeT()
            {
                //// SETUP

                var testEntities = new List<TestEntity>
                    {
                        new TestEntity { Name = "One" },
                        new TestEntity { Name = "Two" },
                        new TestEntity { Name = "Three" }
                    };

                using (var session = GetInMemoryDatabaseSession())
                {
                    // Add the test entities.
                    using (var transaction = session.BeginTransaction())
                    {
                        foreach (var entity in testEntities)
                        {
                            session.Save(entity);
                        }

                        transaction.Commit();
                    }

                    // Mock session factory that will provide the in-memory session.
                    var mockSessionFactory = new Mock<ISessionFactory>();
                    mockSessionFactory.Setup(mock => mock.OpenSession()).Returns(session);

                    // Setup target
                    var target = new NHibernateReadOnlyRepository<TestEntity>(mockSessionFactory.Object);

                    // EXECUTE
                    var query = target.All();

                    //// VERIFY

                    var actual = query.ToList();

                    Assert.AreEqual(testEntities.Count, actual.Count);
                    foreach (var entity in testEntities)
                    {
                        Assert.True(actual.Contains(entity));
                    }
                }
            }
            public void ReturnsNullForNoMatches()
            {
                //// SETUP

                var testEntities = new List<TestEntity>
                    {
                        new TestEntity { Name = "One" },
                        new TestEntity { Name = "Two" },
                        new TestEntity { Name = "Three" }
                    };

                using (var session = GetInMemoryDatabaseSession())
                {
                    // Add the test entities.
                    using (var transaction = session.BeginTransaction())
                    {
                        foreach (var entity in testEntities)
                        {
                            session.Save(entity);
                        }

                        transaction.Commit();
                    }

                    // Mock session factory that will provide the in-memory session.
                    var mockSessionFactory = new Mock<ISessionFactory>();
                    mockSessionFactory.Setup(mock => mock.OpenSession()).Returns(session);

                    // Setup target
                    var target = new NHibernateReadOnlyRepository<TestEntity>(mockSessionFactory.Object);

                    // EXECUTE
                    var actual = target.FindBy(x => x.Name.StartsWith("X"));

                    // VERIFY
                    Assert.Null(actual);
                }
            }