Esempio n. 1
0
        public void CreateTestPack()
        {
            SetupDBConnection();
            new Engine();
            new Address();
            ContactPerson.DeleteAllContactPeople();
            new Car();
            CreateUpdatedContactPersonTestPack();


            _contactPersonUpdateConcurrency         = new ContactPerson();
            _contactPersonUpdateConcurrency.Surname = "Update Concurrency";
            _contactPersonUpdateConcurrency.Save();


            _contactPBeginEditsConcurrency         = new ContactPerson();
            _contactPBeginEditsConcurrency.Surname = "BeginEdits Concurrency";
            _contactPBeginEditsConcurrency.Save();

            _contactPTestRefreshFromObjMan         = new ContactPerson();
            _contactPTestRefreshFromObjMan.Surname = "FirstSurname";
            _contactPTestRefreshFromObjMan.Save();
            new Engine();
            CreateDeletedPersonTestPack();
            CreateSaveContactPersonTestPack();

            //Ensure that a fresh object is loaded from DB
            FixtureEnvironment.ClearBusinessObjectManager();
        }
        public void TestFixBug_SearchGridSearchesTheGrid_DoesNotCallFilterOnGridbase()
        {
            //FirstName is not in the grid def therefore if the grid calls the filter gridbase filter
            // the dataview will try to filter with a column that does not exist this will raise an error
            //---------------Set up test pack-------------------
            //Clear all contact people from the DB
            ContactPerson.DeleteAllContactPeople();
            IClassDef classDef = ContactPersonTestBO.LoadDefaultClassDefWithUIDef();

            CreateContactPersonInDB();

            //Create grid setup for search
            IEditableGridControl gridControl = CreateEditableGridControl();

            ITextBox txtboxFirstName = gridControl.FilterControl.AddStringFilterTextBox("FirstName", "FirstName");

            gridControl.Initialise(classDef);
            gridControl.FilterMode = FilterModes.Search;
            //---------------Execute Test ----------------------
            txtboxFirstName.Text = "FFF";
            gridControl.FilterControl.ApplyFilter();
            //---------------Test Result -----------------------
            Assert.IsTrue(true); //No error was thrown by the grid.
            //---------------Tear Down -------------------------
        }
        public void TestAcceptance_SearchGridSearchesTheGrid()
        {
            //---------------Set up test pack-------------------
            //Clear all contact people from the DB
            ContactPerson.DeleteAllContactPeople();
            IClassDef classDef = ContactPersonTestBO.LoadDefaultClassDefWithUIDef();

            //Create data in the database with the 5 contact people two with Search in surname
            CreateContactPersonInDB();
            CreateContactPersonInDB();
            CreateContactPersonInDB();
            CreateContactPersonInDB_With_SSSSS_InSurname();
            CreateContactPersonInDB_With_SSSSS_InSurname();
            //Create grid setup for search
            IEditableGridControl gridControl = CreateEditableGridControl();
            ITextBox             txtbox      = gridControl.FilterControl.AddStringFilterTextBox("Surname", "Surname");

            gridControl.Initialise(classDef);
            gridControl.FilterMode = FilterModes.Search;

            //--------------Assert PreConditions----------------
            //No items in the grid
            Assert.AreEqual(1, gridControl.Grid.Rows.Count);

            //---------------Execute Test ----------------------
            //set data in grid to a value that should return 2 people
            const string filterByValue = "SSSSS";

            txtbox.Text = filterByValue;
            //grid.filtercontrols.searchbutton.click
            gridControl.OrderBy = "Surname";
            gridControl.FilterControl.ApplyFilter();

            //---------------Test Result -----------------------
            StringAssert.Contains(filterByValue,
                                  gridControl.FilterControl.GetFilterClause().GetFilterClauseString());
            //verify that there are 2 people in the grid.
            Assert.AreEqual(3, gridControl.Grid.Rows.Count);

            BusinessObjectCollection <ContactPersonTestBO> col = new BusinessObjectCollection <ContactPersonTestBO>();

            col.Load("Surname like %" + filterByValue + "%", "Surname");
            Assert.AreEqual(col.Count + 1, gridControl.Grid.Rows.Count);
            int rowNum = 0;

            foreach (ContactPersonTestBO person in col)
            {
                object rowID = gridControl.Grid.Rows[rowNum++].Cells["HABANERO_OBJECTID"].Value;
                Assert.AreEqual(person.ID.ToString(), rowID.ToString());
            }
            //---------------Tear Down -------------------------
            ContactPerson.DeleteAllContactPeople();
        }
        public void TestSetupComboBoxFromClassDef_SetsItemsInComboBox()
        {
            //---------------Set up test pack-------------------
            IClassDef classDef = ContactPersonTestBO.LoadClassDefOrganisationTestBORelationship_MultipleReverse();

            OrganisationTestBO.LoadDefaultClassDef();
            ContactPerson.DeleteAllContactPeople();
            OrganisationTestBO.ClearAllFromDB();
            OrganisationTestBO.CreateSavedOrganisation();
            OrganisationTestBO.CreateSavedOrganisation();
            ContactPersonTestBO.CreateSavedContactPersonNoAddresses();
            TestUtil.WaitForGC();
            BusinessObjectCollection <ContactPersonTestBO> col = new BusinessObjectCollection <ContactPersonTestBO>();

            col.LoadAll();

            IEditableGridControl gridControl     = GetControlFactory().CreateEditableGridControl();
            GridInitialiser      gridInitialiser = new GridInitialiser(gridControl, GetControlFactory());

            //--------------Assert PreConditions----------------
            Assert.AreEqual(0, gridControl.Grid.Columns.Count);
            Assert.AreEqual(1, classDef.UIDefCol.Count);
            const string uiDefName = "default";
            IUIGrid      uiGridDef = classDef.UIDefCol[uiDefName].UIGrid;

            Assert.IsNotNull(uiGridDef);
            Assert.AreEqual(1, uiGridDef.Count);
            Assert.AreEqual(1, col.Count);
            Assert.AreEqual(2,
                            BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObjectCollection <OrganisationTestBO>
                                ("").Count);

            //---------------Execute Test ----------------------
            gridInitialiser.InitialiseGrid(classDef, uiDefName);

            //---------------Test Result -----------------------
            Assert.AreEqual(2, gridControl.Grid.Columns.Count, "Should have ID column and should have comboBoxColumn");
            IDataGridViewColumn dataGridViewColumn = gridControl.Grid.Columns[1];

            AssertIsComboBoxColumnType(dataGridViewColumn);
            AssertComboBoxItemCount(dataGridViewColumn, 3);
        }
        public void Test_ThrowErrorIfObjectDeletedPriorToBeginEdits()
        {
            //---------------Set up test pack-------------------
            ContactPersonPessimisticLockingDB cp = CreateSavedContactPersonPessimisticLocking();

            //---------------Execute Test ----------------------
            ContactPerson.DeleteAllContactPeople();
            try
            {
                IConcurrencyControl concurrCntrl = cp.ConcurrencyControl();
                concurrCntrl.CheckConcurrencyBeforeBeginEditing();
                Assert.Fail();
            }
            //---------------Test Result -----------------------
            catch (BusObjDeleteConcurrencyControlException ex)
            {
                Assert.IsTrue(
                    ex.Message.Contains(
                        "You cannot save the changes to 'ContactPersonPessimisticLockingDB', as another user has deleted the record"));
            }
        }
Esempio n. 6
0
        public void TestLoadedObjectIsAddedToObjectManager()
        {
            //---------------Set up test pack-------------------
            ContactPerson.DeleteAllContactPeople();
            SetupDefaultContactPersonBO();
            ContactPersonTestBO contactPerson1 = ContactPersonTestBO.CreateSavedContactPerson
                                                     (Guid.NewGuid().ToString("N"), Guid.NewGuid().ToString("N"));

            FixtureEnvironment.ClearBusinessObjectManager();

            //---------------Assert Precondition----------------
            Assert.AreEqual(0, BORegistry.BusinessObjectManager.Count);

            //---------------Execute Test ----------------------
            ContactPersonTestBO contactPerson =
                BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObject <ContactPersonTestBO>
                    (contactPerson1.ID);

            //---------------Test Result -----------------------
            Assert.AreEqual(1, BORegistry.BusinessObjectManager.Count);
            Assert.IsTrue(BORegistry.BusinessObjectManager.Contains(contactPerson));
        }