示例#1
0
 public void TotalTest()
 {
     QueryResponse target = new QueryResponse();
     int expected = 0;
     Assert.AreEqual(expected, target.Total);
 }
示例#2
0
 public void QueryResponseConstructorTest()
 {
     QueryResponse target = new QueryResponse();
     Assert.IsNotNull(target);
 }
示例#3
0
 public void SubjectsTest()
 {
     QueryResponse target = new QueryResponse();
     List<TestSubject> expected = null;
     Assert.AreEqual(expected, target.Subjects);
 }
示例#4
0
        /// <summary>
        /// See <see cref="IDataStore"/> for method descriptions.
        /// </summary>
        public QueryResponse GetData(PageOptions paging)
        {
            QueryResponse response = new QueryResponse();
            IEnumerable<TestSubject> results = new List<TestSubject>();
            if (paging == null)
            {
                paging = new PageOptions();
            }
            if (paging.SortBy == PageOptions.Sort.FirstName)
                results = datastore.OrderBy(e => e.FirstName);
            else if (paging.SortBy == PageOptions.Sort.LastName)
                results = datastore.OrderBy(e => e.LastName);
            else if (paging.SortBy == PageOptions.Sort.Email)
                results = datastore.OrderBy(e => e.Email);
            else if (paging.SortBy == PageOptions.Sort.Password)
                results = datastore.OrderBy(e => e.Password);

            response.Subjects = results.Skip(paging.PageNumber * 5).Take(5).ToList();
            response.Total = datastore.Count;

            return response;
        }