Beispiel #1
0
        private void SetRowsCount()
        {
            BusinessObjectCollection <T> col = new BusinessObjectCollection <T>();
            int recordCount;

            col.LoadWithLimit("", Sort, 0, 0, out recordCount);
            this.RowCount = recordCount;
        }
Beispiel #2
0
        /// <summary>
        /// Gets a objects list for the specified page
        /// </summary>
        /// <param name="pageNumber"></param>
        /// <param name="rowsPerPage"></param>
        /// <returns></returns>
        protected virtual IList <T> GetDataPage(int pageNumber, int rowsPerPage)
        {
            _bindingListRequest.PageNumber  = pageNumber;
            _bindingListRequest.RowsPerPage = rowsPerPage;

            BusinessObjectCollection <T> col = new BusinessObjectCollection <T>();
            int recordCount;

            col.LoadWithLimit(Filter, Sort, _bindingListRequest.StartIndex, _bindingListRequest.RowsPerPage, out recordCount);
            this.RowCount = recordCount;
            return(col);
        }
 public void Test_CollectionLoad_LoadWithLimit_FirstNegative_ThrowsError()
 {
     const int totalRecords = 3;
     const int firstRecord = -1;
     const int limit = 0;
     SetupDefaultContactPersonBO();
     ContactPersonTestBO[] contactPersonTestBOs = CreateSavedContactPeople(totalRecords);
     BusinessObjectCollection<ContactPersonTestBO> col = new BusinessObjectCollection<ContactPersonTestBO>();
     //---------------Assert Precondition----------------
     Assert.AreEqual(totalRecords, contactPersonTestBOs.Length);
     //---------------Execute Test ----------------------
     try
     {
         int totalNoOfRecords;
         col.LoadWithLimit("", "Surname", firstRecord, limit, out totalNoOfRecords);
         //---------------Test Result -----------------------
         Assert.Fail("IndexOutOfRangeException exception expected");
     }
     catch (IndexOutOfRangeException ex)
     {
         Assert.AreEqual("FirstRecordToLoad should not be negative.", ex.Message);
     }
 }
 public void Test_CollectionLoad_LoadWithLimit_FirstAtEnd_LimitBeyondEnd_RefreshWithAdditionalBO()
 {
     const int totalRecords = 5;
     const int firstRecord = totalRecords - 1;
     const int limit = 3;
     SetupDefaultContactPersonBO();
     var contactPersonTestBOs = CreateSavedContactPeople(totalRecords);
     var contactPersonTestBOsPlusOne = new ContactPersonTestBO[totalRecords + 1];
     contactPersonTestBOs.CopyTo(contactPersonTestBOsPlusOne, 0);
     var col = new BusinessObjectCollection<ContactPersonTestBO>();
     int totalNoOfRecords;
     col.LoadWithLimit("", "Surname", firstRecord, limit, out totalNoOfRecords);
     contactPersonTestBOsPlusOne[totalRecords] = ContactPersonTestBO.CreateSavedContactPerson
         ("ZZZZZZZZZZZZZZZZZ");
     //---------------Assert Precondition----------------
     Assert.AreEqual(1, col.Count);
     Assert.AreEqual(totalRecords, contactPersonTestBOs.Length);
     Assert.AreEqual(totalRecords + 1, contactPersonTestBOsPlusOne.Length);
     //---------------Execute Test ----------------------
     col.Refresh();
     //---------------Test Result -----------------------
     totalNoOfRecords++;
     AssertLimitedResultsCorrect
         (firstRecord, limit, totalRecords + 1, 2, contactPersonTestBOsPlusOne, col, totalNoOfRecords);
 }
 public void Test_CollectionLoad_LoadWithLimit_FirstAfterEnd_LimitZero()
 {
     const int totalRecords = 3;
     const int firstRecord = 4;
     const int limit = 0;
     SetupDefaultContactPersonBO();
     var contactPersonTestBOs = CreateSavedContactPeople(totalRecords);
     var col = new BusinessObjectCollection<ContactPersonTestBO>();
     //---------------Assert Precondition----------------
     Assert.AreEqual(totalRecords, contactPersonTestBOs.Length);
     //---------------Execute Test ----------------------
     int totalNoOfRecords;
     col.LoadWithLimit("", "Surname", firstRecord, limit, out totalNoOfRecords);
     //---------------Test Result -----------------------
     AssertLimitedResultsCorrect
         (firstRecord, limit, totalRecords, 0, contactPersonTestBOs, col, totalNoOfRecords);
 }
        public void Test_CollectionLoad_LoadWithLimit_CriteriaObject_IncludesCriteriaMatchesWithinLimit()
        {
            //---------------Set up test pack-------------------
            SetupDefaultContactPersonBO();
            DateTime now = DateTime.Now;
            ContactPersonTestBO cp1 = ContactPersonTestBO.CreateSavedContactPerson(now, "aaa");
            ContactPersonTestBO cpLast = ContactPersonTestBO.CreateSavedContactPerson(now, "zzz");
            ContactPersonTestBO cp2 = ContactPersonTestBO.CreateSavedContactPerson(now, "hhh");
            ContactPersonTestBO.CreateSavedContactPerson(DateTime.Now.AddDays(-3), "bbb");

            BusinessObjectCollection<ContactPersonTestBO> col = new BusinessObjectCollection<ContactPersonTestBO>();
            Criteria criteria = new Criteria("DateOfBirth", Criteria.ComparisonOp.GreaterThan, now.AddHours(-1));
            //---------------Assert Precondition ---------------


            //---------------Execute Test ----------------------
            //            BORegistry.DataAccessor.BusinessObjectLoader.Refresh(col);
            col.LoadWithLimit(criteria, "Surname", 2);

            //---------------Test Result -----------------------
            Assert.AreEqual(2, col.Count);
            Assert.AreSame(cp1, col[0]);
            Assert.AreSame(cp2, col[1]);
            Assert.IsFalse(col.Contains(cpLast));
        }
 public void Test_CollectionLoad_LoadWithLimit_FirstAfterStart_LimitBeforeEnd()
     //_NoRecords_StartRecords_First2Records()
 {
     const int totalRecords = 6;
     const int firstRecord = 2;
     const int limit = 2;
     SetupDefaultContactPersonBO();
     ContactPersonTestBO[] contactPersonTestBOs = CreateSavedContactPeople(totalRecords);
     BusinessObjectCollection<ContactPersonTestBO> col = new BusinessObjectCollection<ContactPersonTestBO>();
     //---------------Assert Precondition----------------
     Assert.AreEqual(totalRecords, contactPersonTestBOs.Length);
     //---------------Execute Test ----------------------
     int totalNoOfRecords;
     col.LoadWithLimit("", "Surname", firstRecord, limit, out totalNoOfRecords);
     //---------------Test Result -----------------------
     AssertLimitedResultsCorrect
         (firstRecord, limit, totalRecords, limit, contactPersonTestBOs, col, totalNoOfRecords);
 }
 public void Test_CollectionLoad_LoadWithLimit_WithSortCriteriaNullString_WhenCompositePK_ShouldNotRaiseError_FixBug567()
 {
     ContactPersonCompositeKey.DeleteAllContactPeople();
     const int totalRecords = 6;
     const int firstRecord = 2;
     const int limit = 2;
     const int expectedCount = 2;
     ContactPersonCompositeKey.LoadClassDefs();
     ContactPersonCompositeKey[] contactPersonTestBOs = CreateCompositeContactPeople(totalRecords);
     IBusinessObjectCollection col = new BusinessObjectCollection<ContactPersonCompositeKey>();
     //---------------Assert Precondition----------------
     Assert.AreEqual(totalRecords, contactPersonTestBOs.Length);
     //---------------Execute Test ----------------------
     int totalNoOfRecords;
     col.LoadWithLimit((string)null, (string)null, firstRecord, limit, out totalNoOfRecords);
     //---------------Test Result -----------------------
     Assert.AreEqual
         (totalRecords, totalNoOfRecords, "The returned total number of availabe records is incorrect");
     Assert.AreEqual
         (firstRecord, col.SelectQuery.FirstRecordToLoad,
          "Collection query FirstRecordToLoad does not match expectation.");
     Assert.AreEqual
         (limit, col.SelectQuery.Limit, "Collection query limit does not match expectation.");
     Assert.AreEqual(expectedCount, col.Count, "Collection size does not match expectation.");
 }
 public void Test_CollectionLoad_LoadWithLimit_WithSortCriteriaEmptyString_ShouldNotRaiseError_FixBug566()
 {
     ContactPersonTestBO.DeleteAllContactPeople();
     const int totalRecords = 3;
     const int firstRecord = 0;
     const int limit = 2;
     const int expectedCount = 2;
     SetupDefaultContactPersonBO();
     ContactPersonTestBO[] contactPersonTestBOs = CreateSavedSortedContactPeople(totalRecords);
     IBusinessObjectCollection col = new BusinessObjectCollection<ContactPersonTestBO>();
     //---------------Assert Precondition----------------
     Assert.AreEqual(totalRecords, contactPersonTestBOs.Length);
     //---------------Execute Test ----------------------
     int totalNoOfRecords;
     col.LoadWithLimit("", "", firstRecord, limit, out totalNoOfRecords);
     //---------------Test Result -----------------------
     Assert.AreEqual
         (totalRecords, totalNoOfRecords, "The returned total number of availabe records is incorrect");
     Assert.AreEqual
         (firstRecord, col.SelectQuery.FirstRecordToLoad,
          "Collection query FirstRecordToLoad does not match expectation.");
     Assert.AreEqual
         (limit, col.SelectQuery.Limit, "Collection query limit does not match expectation.");
     Assert.AreEqual(expectedCount, col.Count, "Collection size does not match expectation.");
 }
        public void Test_CollectionLoad_LoadWithLimit_WithSearchCriteriaNullString_ShouldNotRaiseError_FixBug565()
        {
            ContactPersonTestBO.DeleteAllContactPeople();
            const int totalRecords = 3;
            const int firstRecord = 0;
            const int limit = 2;
            const int expectedCount = 2;

            SetupDefaultContactPersonBO();
            ContactPersonTestBO[] contactPersonTestBOs = CreateSavedSortedContactPeople(totalRecords);
            IBusinessObjectCollection col = new BusinessObjectCollection<ContactPersonTestBO>();
            //---------------Assert Precondition----------------
            Assert.AreEqual(totalRecords, contactPersonTestBOs.Length);
            //---------------Execute Test ----------------------

            int totalNoOfRecords;
            col.LoadWithLimit((string)null, "Surname", firstRecord, limit, out totalNoOfRecords);
            //---------------Test Result -----------------------
            AssertLimitedResultsCorrect
                (firstRecord, limit, totalRecords, expectedCount, contactPersonTestBOs, col, totalNoOfRecords);
        }
        public void Test_CollectionLoad_LoadWithLimit_NoRecords2_StartRecord1_UsingWhereClause()
        {
            SetupDefaultContactPersonBO();
            ContactPersonTestBO cp1 = ContactPersonTestBO.CreateSavedContactPerson("eeeee");
            ContactPersonTestBO.CreateSavedContactPerson("gggggg");
            ContactPersonTestBO.CreateSavedContactPerson("gggdfasd");
            ContactPersonTestBO.CreateSavedContactPerson("bbbbbb");
            ContactPersonTestBO.CreateSavedContactPerson("zazaza");
            ContactPersonTestBO.CreateSavedContactPerson("zbbbbb");
            ContactPersonTestBO.CreateSavedContactPerson("zccccc");
            ContactPersonTestBO.CreateSavedContactPerson("zddddd");
            BusinessObjectCollection<ContactPersonTestBO> col = new BusinessObjectCollection<ContactPersonTestBO>();
            int totalNoOfRecords;
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            col.LoadWithLimit("Surname Not Like 'z%'", "Surname", 1, 2, out totalNoOfRecords);
            //---------------Test Result -----------------------
            Assert.AreEqual(1, col.SelectQuery.FirstRecordToLoad);
            Assert.AreEqual(2, col.SelectQuery.Limit);
            Assert.AreEqual(2, col.Count);
            Assert.AreSame(cp1, col[0]);
        }
 public void Test_LoadWithLimit_LoadWithLimit_FirstAtEnd_LimitEqualsEnd()
 {
     const int totalRecords = 4;
     const int firstRecord = totalRecords - 1;
     const int limit = 1;
     ContactPersonTestBO.LoadDefaultClassDef();
     ContactPersonTestBO[] contactPersonTestBOs = CreateSavedSortedContactPeople(totalRecords);
     IBusinessObjectCollection col = new BusinessObjectCollection<ContactPersonTestBO>();
     //---------------Assert Precondition----------------
     Assert.AreEqual(totalRecords, contactPersonTestBOs.Length);
     //---------------Execute Test ----------------------
     int totalNoOfRecords;
     col.LoadWithLimit("", "Surname", firstRecord, limit, out totalNoOfRecords);
     //---------------Test Result -----------------------
     AssertLimitedResultsCorrect
         (firstRecord, limit, totalRecords, limit, contactPersonTestBOs, col, totalNoOfRecords);
 }