コード例 #1
0
        public override void TestGetBusinessObjectAtRow_WhenGridHasObjectIDButBOColNotHasObject_ShouldLoadBO()
        {
            //This is a fairly specific situation but can occur when you are using
            // a CachedBindingList or a paginaged BindingList where the BOCol that the
            // grid has reference to does not have any BusinessObjects.
            //---------------Set up test pack-------------------
            MyBO.LoadDefaultClassDef();
            BusinessObjectCollection <MyBO> col = CreateCollectionWith_4_SavedObjects();

            IGridBase gridBase    = CreateGridBaseStub();
            var       loaderClass = new CustomDelegateLoaderClass(col);

            gridBase.GridLoader = loaderClass.GridLoaderDelegateLoadFromDiffCol;
            SetupGridColumnsForMyBo(gridBase);
            gridBase.BusinessObjectCollection = new BusinessObjectCollection <MyBO>();
            //---------------Assert Preconditions---------------
            Assert.IsNull(gridBase.DataSetProvider);
            Assert.IsNotNull(gridBase.DataSource);
            col.Refresh();
            Assert.AreEqual(4, col.Count);
            Assert.AreEqual(4, gridBase.RowCount);
            //---------------Execute Test ----------------------
            IBusinessObject businessObject2 = gridBase.GetBusinessObjectAtRow(2);
            IBusinessObject businessObject3 = gridBase.GetBusinessObjectAtRow(3);

            //---------------Test Result -----------------------
            Assert.AreSame(col[2], businessObject2);
            Assert.AreSame(col[3], businessObject3);
        }
コード例 #2
0
        public void TestGetBusinessObjectAtRow_2()
        {
            //---------------Set up test pack-------------------
            BusinessObjectCollection <MyBO> col;
            IGridBase gridBase = GetGridBaseWith_4_Rows(out col);
            //---------------Execute Test ----------------------
            IBusinessObject businessObject2 = gridBase.GetBusinessObjectAtRow(2);
            IBusinessObject businessObject3 = gridBase.GetBusinessObjectAtRow(3);

            //---------------Test Result -----------------------
            Assert.AreSame(col[2], businessObject2);
            Assert.AreSame(col[3], businessObject3);
        }
コード例 #3
0
        public override void TestGetBusinessObjectAtRow_WhenDataSourceNotNullButDataSetProviderNull_ShouldReturnBO()
        {
            //---------------Set up test pack-------------------
            MyBO.LoadDefaultClassDef();
            BusinessObjectCollection <MyBO> col = CreateCollectionWith_4_Objects();
            IGridBase gridBase = CreateGridBaseStub();

            gridBase.GridLoader = GridLoaderDelegateSetDataSource;
            SetupGridColumnsForMyBo(gridBase);
            gridBase.BusinessObjectCollection = col;
            //---------------Assert Preconditions---------------
            Assert.IsNull(gridBase.DataSetProvider);
            Assert.IsNotNull(gridBase.DataSource);
            //---------------Execute Test ----------------------
            IBusinessObject businessObject2 = gridBase.GetBusinessObjectAtRow(2);
            IBusinessObject businessObject3 = gridBase.GetBusinessObjectAtRow(3);

            //---------------Test Result -----------------------
            Assert.AreSame(col[2], businessObject2);
            Assert.AreSame(col[3], businessObject3);
        }
コード例 #4
0
        public override void TestGetBusinessObjectRow()
        {
            //---------------Set up test pack-------------------
            BusinessObjectCollection <MyBO> col;
            IGridBase gridBase      = GetGridBaseWith_4_Rows(out col);
            MyBO      myBO2         = col[2];
            const int expectedIndex = 2;

            //-------------Assert Preconditions -------------
            Assert.AreSame(myBO2, gridBase.GetBusinessObjectAtRow(expectedIndex));
            //---------------Execute Test ----------------------
            IDataGridViewRow dataGridViewRow = gridBase.GetBusinessObjectRow(myBO2);

            //---------------Test Result -----------------------
            Assert.IsNotNull(dataGridViewRow, "Should return related row");
            Assert.AreEqual(expectedIndex, dataGridViewRow.Index);
        }
コード例 #5
0
        public void TestVWG_Set_BusinessObjectCollection()
        {
            //---------------Set up test pack-------------------
            MyBO.LoadDefaultClassDef();
            BusinessObjectCollection <MyBO> col = CreateCollectionWith_4_Objects();
            IGridBase gridBase = CreateGridBaseStub();

            SetupGridColumnsForMyBo(gridBase);
            const string propName = "TestProp";
            const int    rowIndex = 1;

            //---------------Execute Test ----------------------
            gridBase.BusinessObjectCollection = col;

            //---------------Test Result -----------------------
            MyBO              selectedBo = (MyBO)gridBase.GetBusinessObjectAtRow(rowIndex);
            IDataGridViewRow  row        = gridBase.Rows[rowIndex];
            IDataGridViewCell cell       = row.Cells[propName];

            Assert.AreEqual(selectedBo.TestProp, cell.Value);
        }
コード例 #6
0
        public void TestVWG_RowShowingBusinessObjectsValues()
        {
            //---------------Set up test pack-------------------
            MyBO.LoadDefaultClassDef();
            BusinessObjectCollection <MyBO> col = CreateCollectionWith_4_Objects();
            IGridBase gridBase = CreateGridBaseStub();

            SetupGridColumnsForMyBo(gridBase);
            const string propName = "TestProp";
            const int    rowIndex = 1;

            //---------------Execute Test ----------------------
#pragma warning disable 618,612 //Maintained for backward compatibility testing
            gridBase.SetBusinessObjectCollection(col);
#pragma warning restore 618,612

            //---------------Test Result -----------------------
            MyBO              selectedBo = (MyBO)gridBase.GetBusinessObjectAtRow(rowIndex);
            IDataGridViewRow  row        = gridBase.Rows[rowIndex];
            IDataGridViewCell cell       = row.Cells[propName];
            Assert.AreEqual(selectedBo.TestProp, cell.Value);
        }