public void Should_be_able_to_execute_read_and_write_queries_to_same_session()
 {
     //arrange
     var b1 = new Book { Title = "The Silmarillion" };
     var crit = new SearchCriteria
     {
         Compare = ComparisonType.Equals,
         PropertyName = "Title",
         Value = "The Silmarillion"
     };
     //act
     _repo.Create(b1);
     var b2 = _repo.Search(crit)[0];
     _repo.Delete(b1);
     //assert 
     Assert.AreEqual(b1.Title, b2.Title);
 }
        public void Should_be_able_to_Search_by_SQL()
        {
            //arrange
            var advCrit = new AdvancedSearchCriteria();
            var crit = new SearchCriteria();
            crit.Compare = ComparisonType.SqlExp;
            crit.Value = "Condition = 1";
            advCrit.SearchFilter = new List<SearchCriteria> { crit };
            advCrit.OrderBy = new List<OrderCriteria>();

            var expectedTitle = "The Hobbit";
            var expectedRecords = 2;
            //act
            var books = _repo.Search(advCrit);
            var actualTitle = books[0].Title;
            var actualRecords = books.Count;
            //assert
            Assert.AreEqual(expectedRecords, actualRecords);
            Assert.AreEqual(expectedTitle, actualTitle);
        }
        public void Should_be_able_to_Search_by_InGuid()
        {
            //arrange
            var advCrit = new AdvancedSearchCriteria();
            var crit = new SearchCriteria();
            crit.Compare = ComparisonType.InGUID;
            crit.PropertyName = "BookGuid";
            crit.Value = new List<Guid> { new Guid("11111111-1111-1111-1111-111111111111"), new Guid(), new Guid("33333333-3333-3333-3333-333333333333") };
            advCrit.SearchFilter = new List<SearchCriteria> { crit };
            advCrit.OrderBy = new List<OrderCriteria>();

            var expectedTitle = "The Hobbit";
            var expectedRecords = 2;
            //act
            var books = _repo.Search(advCrit);
            var actualTitle = books[0].Title;
            var actualRecords = books.Count;
            //assert
            Assert.AreEqual(expectedRecords, actualRecords);
            Assert.AreEqual(expectedTitle, actualTitle);
        }
        public void Should_be_able_to_Search_by_InInt()
        {
            //arrange
            var advCrit = new AdvancedSearchCriteria();
            var crit = new SearchCriteria();
            crit.Compare = ComparisonType.InInt;
            crit.PropertyName = "Condition";
            crit.Value = new List<int> { 2, 3, 4 };
            advCrit.SearchFilter = new List<SearchCriteria> { crit };
            advCrit.OrderBy = new List<OrderCriteria>();

            var expectedTitle = "Fellowship of the Ring";
            var expectedRecords = 1;
            //act
            var books = _repo.Search(advCrit);
            var actualTitle = books[0].Title;
            var actualRecords = books.Count;
            //assert
            Assert.AreEqual(expectedRecords, actualRecords);
            Assert.AreEqual(expectedTitle, actualTitle);
        }
        public void Should_be_able_to_Search_by_InString()
        {
            //arrange
            var advCrit = new AdvancedSearchCriteria();
            var crit = new SearchCriteria();
            crit.Compare = ComparisonType.InString;
            crit.PropertyName = "Title";
            crit.Value = new List<String> { "The Hobbit", "Starship Troopers", "The Two Towers" };
            advCrit.SearchFilter = new List<SearchCriteria> { crit };
            advCrit.OrderBy = new List<OrderCriteria>();

            var expectedTitle = "The Hobbit";
            var expectedRecords = 2;
            //act
            var books = _repo.Search(advCrit);
            var actualTitle = books[0].Title;
            var actualRecords = books.Count;
            //assert
            Assert.AreEqual(expectedRecords, actualRecords);
            Assert.AreEqual(expectedTitle, actualTitle);
        }
        public void Should_be_able_to_Search_by_LikeAnywhere()
        {
            //arrange
            var advCrit = new AdvancedSearchCriteria();
            var crit = new SearchCriteria();
            crit.Compare = ComparisonType.LikeAnywhere;
            crit.PropertyName = "Title";
            crit.Value = "The";
            advCrit.SearchFilter = new List<SearchCriteria> { crit };
            advCrit.OrderBy = new List<OrderCriteria>();

            var expectedTitle = "The Hobbit";
            var expectedRecords = 4;
            //act
            var books = _repo.Search(advCrit);
            var actualTitle = books[0].Title;
            var actualRecords = books.Count;
            //assert
            Assert.AreEqual(expectedRecords, actualRecords);
            Assert.AreEqual(expectedTitle, actualTitle);
        }