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_and_Sort()
 {
     //arrange
     var advCrit = new AdvancedSearchCriteria();
     advCrit.SearchFilter = new List<SearchCriteria>();
     advCrit.OrderBy = new List<OrderCriteria> { new OrderCriteria { PropertyName = "Title" } };
     advCrit.StartingIndex = 2;
     advCrit.TotalRecords = 1;
     var expectedTitle = "The Hobbit";
     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_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);
        }
 public void Should_be_able_to_Sort_Descending()
 {
     //arrange
     var advCrit = new AdvancedSearchCriteria();
     advCrit.SearchFilter = new List<SearchCriteria>();
     advCrit.OrderBy = new List<OrderCriteria> { new OrderCriteria { PropertyName = "Title", Order = OrderType.DESC } };
     advCrit.StartingIndex = 0;
     advCrit.TotalRecords = 2;
     var expectedTitle = "The Two Towers";
     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);
 }