예제 #1
0
 public void CanSetSortOrder()
 {
     var query = new NameValueCollection();
     query.Add("sort", "IP");
     var q = new LogQuery(query);
     Assert.AreEqual("IP", q.Sort);
 }
 public void CanCount()
 {
     var query = new LogQuery();
     var repo = new ReaderRepository();
     var count = repo.Count(query);
     Assert.Greater(count, 0);
 }
 public void CanClearLog()
 {
     var reader = new ReaderRepository();
     var query = new LogQuery();
     writer.Clear();
     var count = reader.Count(query);
     Assert.AreEqual(0, count);
 }
예제 #4
0
 public void CanSetPageNumberAndOrdering(string order, bool expectedOrder)
 {
     var query = new NameValueCollection();
     query.Add("page", "5");
     query.Add("order", order);
     var q = new LogQuery(query);
     Assert.AreEqual(5, q.PageNumber);
     Assert.AreEqual(expectedOrder, q.Ascending);
 }
예제 #5
0
 public void CanSetFilter()
 {
     var query = new NameValueCollection();
     query.Add("filter", "IP");
     query.Add("filtervalue", "::1");
     var q = new LogQuery(query);
     Assert.AreEqual("IP", q.Filter);
     Assert.AreEqual("::1", q.FilterValue);
 }
        public void CanCountFiltered(string filter, string filterValue, int expected)
        {
            var query = new LogQuery() {
                Filter = filter,
                FilterValue = filterValue
            };

            var repo = new ReaderRepository();
            Assert.AreEqual(expected, repo.Count(query));
        }
예제 #7
0
 public void CanGetQueryString
     (string filter, string filterValue, string sort, bool ascending, string expected)
 {
     var q = new LogQuery() {
         Filter = filter,
         FilterValue = filterValue,
         Sort = sort,
         Ascending = ascending
     };
     Assert.AreEqual(expected, q.ToString());
 }
예제 #8
0
 public void CanGetPageNumbers(int pageNumber, int totalPages, params int[] expected)
 {
     var query = new LogQuery() {
         PageNumber = pageNumber
     };
     var results = new LogResultSet() {
         Page = pageNumber,
         TotalPages = totalPages
     };
     var pageNumbers = new Pager(null, query, results).GetPageNumbers();
     CollectionAssert.AreEqual(expected, pageNumbers);
 }
예제 #9
0
 public Pager(Uri baseUrl, LogQuery baseQuery, LogResultSet results)
 {
     this.baseUrl = baseUrl;
     this.baseQuery = baseQuery;
     this.results = results;
 }