コード例 #1
0
        public void TestGridFiringItemSelected()
        {
            //---------------Set up test pack-------------------
            MyBO.LoadDefaultClassDef();
            IReadOnlyGridControl readOnlyGridControl = GetControlFactory().CreateReadOnlyGridControl();

            DisposeOnTearDown(readOnlyGridControl);
            BusinessObjectCollection <MyBO> myBOS = new BusinessObjectCollection <MyBO>();

            myBOS.Add(new MyBO());
            MyBO bo = new MyBO();

            myBOS.Add(bo);
            myBOS.Add(new MyBO());

            readOnlyGridControl.SetBusinessObjectCollection(myBOS);
            bool gridItemSelected = false;

            readOnlyGridControl.Grid.SelectedBusinessObject  = null;
            readOnlyGridControl.Grid.BusinessObjectSelected += (delegate { gridItemSelected = true; });

            //---------------Execute Test ----------------------
            readOnlyGridControl.Grid.SelectedBusinessObject = bo;

            //---------------Test Result -----------------------
            Assert.IsTrue(gridItemSelected);
        }
コード例 #2
0
        public void Test()
        {
            IBusinessObjectCollection collection = new BusinessObjectCollection();

            collection.Add(new Student(2, "B"));
            collection.Add(new Student(1, "C"));
            collection.Add(new Student(3, "A"));

            // 验证算法的有效性
            collection.Comparer = new ComparerByID();
            int id = 0;

            foreach (IBusinessObject obj in collection.GetAll())
            {
                Assert.AreEqual <int>(++id, obj.ID);
            }

            // 替换成另一个算法
            collection.Comparer = new ComparerByName();
            string[] data = new string[3] {
                "A", "B", "C"
            };
            int index = 0;

            foreach (IBusinessObject obj in collection.GetAll())
            {
                Assert.AreEqual <string>(data[index++], obj.Name);
            }
        }
コード例 #3
0
        public void Test_RemoveFromBOCol_WhenNotIsSelected_ShouldNotFireBusinessObjectSelectedEvent()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            var listBox = CreateListBox();
            var manager = CreateListBoxCollectionManager(listBox);

            MyBO.LoadDefaultClassDef();
            var myBoCol       = new BusinessObjectCollection <MyBO>();
            var toBeRemovedBo = new MyBO();

            myBoCol.Add(new MyBO());
            myBoCol.Add(toBeRemovedBo);
            myBoCol.Add(new MyBO());
            manager.BusinessObjectCollection = myBoCol;
            IBusinessObject boFromSelectedEvent  = null;
            bool            boSelectedEventFired = false;

            manager.BusinessObjectSelected += (sender, args) =>
            {
                boFromSelectedEvent  = args.BusinessObject;
                boSelectedEventFired = true;
            };
            //---------------Assert Precondition----------------
            Assert.AreNotSame(toBeRemovedBo, manager.SelectedBusinessObject);
            Assert.IsNull(boFromSelectedEvent);
            Assert.IsFalse(boSelectedEventFired);
            //---------------Execute Test ----------------------
            manager.BusinessObjectCollection.Remove(toBeRemovedBo);
            //---------------Test Result -----------------------
            Assert.IsFalse(boSelectedEventFired);
        }
コード例 #4
0
        public void TestBusinessObjectControlHasDifferentBOWhenTabChanges()
        {
            //---------------Set up test pack-------------------
            IBOColTabControl boColTabControl = GetControlFactory().CreateBOColTabControl();

            IBusinessObjectControl busControl = GetBusinessObjectControlStub();
            boColTabControl.BusinessObjectControl = busControl;

            BusinessObjectCollection<MyBO> myBoCol = new BusinessObjectCollection<MyBO>();
            MyBO firstBo = new MyBO();
            myBoCol.Add(firstBo);
            myBoCol.Add(new MyBO());
            MyBO thirdBO = new MyBO();
            myBoCol.Add(thirdBO);
            boColTabControl.BusinessObjectCollection = myBoCol;

            //---------------Assert Precondition----------------
            Assert.AreEqual(firstBo, boColTabControl.BusinessObjectControl.BusinessObject);

            //---------------Execute Test ----------------------
            boColTabControl.TabControl.SelectedIndex = 2;

            //---------------Test Result -----------------------
            Assert.AreNotSame(firstBo, boColTabControl.BusinessObjectControl.BusinessObject);
            Assert.AreEqual(thirdBO, boColTabControl.BusinessObjectControl.BusinessObject);
        }
コード例 #5
0
        public void TestBusinessObjectControlHasDifferentBOWhenTabChanges()
        {
            //---------------Set up test pack-------------------
            IBOColTabControl boColTabControl = GetControlFactory().CreateBOColTabControl();

            IBusinessObjectControl busControl = GetBusinessObjectControlStub();

            boColTabControl.BusinessObjectControl = busControl;

            BusinessObjectCollection <MyBO> myBoCol = new BusinessObjectCollection <MyBO>();
            MyBO firstBo = new MyBO();

            myBoCol.Add(firstBo);
            myBoCol.Add(new MyBO());
            MyBO thirdBO = new MyBO();

            myBoCol.Add(thirdBO);
            boColTabControl.BusinessObjectCollection = myBoCol;

            //---------------Assert Precondition----------------
            Assert.AreEqual(firstBo, boColTabControl.BusinessObjectControl.BusinessObject);

            //---------------Execute Test ----------------------
            boColTabControl.TabControl.SelectedIndex = 2;

            //---------------Test Result -----------------------
            Assert.AreNotSame(firstBo, boColTabControl.BusinessObjectControl.BusinessObject);
            Assert.AreEqual(thirdBO, boColTabControl.BusinessObjectControl.BusinessObject);
        }
コード例 #6
0
 public void InitialiseCollection()
 {
     _boCol = new BusinessObjectCollection <MultiPropBO>();
     _boCol.Add((MultiPropBO)_classDef.CreateNewBusinessObject());
     _boCol.Add((MultiPropBO)_classDef.CreateNewBusinessObject());
     //_boCol.Add((MultiPropBO)_classDef.CreateNewBusinessObject());
     //_boCol.Add((MultiPropBO)_classDef.CreateNewBusinessObject());
 }
コード例 #7
0
 public void InitialiseCollection()
 {
     _boCol = new BusinessObjectCollection<MultiPropBO>();
     _boCol.Add((MultiPropBO)_classDef.CreateNewBusinessObject());
     _boCol.Add((MultiPropBO)_classDef.CreateNewBusinessObject());
     //_boCol.Add((MultiPropBO)_classDef.CreateNewBusinessObject());
     //_boCol.Add((MultiPropBO)_classDef.CreateNewBusinessObject());
 }
コード例 #8
0
        private static IBusinessObjectCollection GetMyBOColWithTwoBOs()
        {
            BusinessObject            myBO    = new MyBO();
            BusinessObject            myBO2   = new MyBO();
            IBusinessObjectCollection myBOCol = new BusinessObjectCollection <MyBO>();

            myBOCol.Add(myBO);
            myBOCol.Add(myBO2);
            return(myBOCol);
        }
コード例 #9
0
        //[Test]
        //public void Test_ShowGridAndBOEditorControlWinWithSuperClassDef_DatabaseLookupList()
        //{
        //    //--------------- Set up test pack ------------------
        //    ClassDef.ClassDefs.Clear();
        //    OrganisationTestBO.LoadDefaultClassDef();
        //    ContactPersonTestBO.LoadDefaultClassDefWithPersonTestBOSuperClass();
        //    PersonTestBO.LoadDefaultClassDefWithTestOrganisationBOLookup_DatabaseLookupList();

        //    IControlFactory controlFactory = GetControlFactory();
        //    IExtendedComboBox extendedComboBox = CreateExtendedComboBox();
        //    const string propName = "OrganisationID";
        //    ExtendedComboBoxMapper mapper = new ExtendedComboBoxMapper(
        //        extendedComboBox, propName, true, controlFactory);
        //    DatabaseConfig databaseConfig = TestUtil.GetDatabaseConfig();
        //    DatabaseConnection.CurrentConnection = databaseConfig.GetDatabaseConnection();
        //    mapper.BusinessObject = new ContactPersonTestBO();
        //   // mapper.RelatedBusinessObject = OrganisationTestBO.CreateSavedOrganisation();
        //    //--------------- Test Preconditions ----------------
        //    Assert.IsNull(mapper.PopupForm);
        //    //--------------- Execute Test ----------------------
        //    //extendedComboBox.Button.PerformClick();
        //    mapper.SetupPopupForm();
        //    //--------------- Test Result -----------------------
        //    Assert.IsNotNull(mapper.PopupForm);
        //}

        private static BusinessObjectCollection <OrganisationTestBO> CreateSavedOrganisationTestBOSCollection()
        {
            OrganisationTestBO.LoadDefaultClassDef();
            BusinessObjectCollection <OrganisationTestBO> organisationTestBOS = new BusinessObjectCollection <OrganisationTestBO>();

            organisationTestBOS.Add(OrganisationTestBO.CreateSavedOrganisation());
            organisationTestBOS.Add(OrganisationTestBO.CreateSavedOrganisation());
            organisationTestBOS.Add(OrganisationTestBO.CreateSavedOrganisation());
            organisationTestBOS.Add(OrganisationTestBO.CreateSavedOrganisation());
            return(organisationTestBOS);
        }
コード例 #10
0
        private static IBusinessObjectCollection GetCol_BO_2Items(IClassDef classDef)
        {
            IBusinessObjectCollection col = new BusinessObjectCollection <BusinessObject>(classDef);
            IBusinessObject           bo1 = classDef.CreateNewBusinessObject();

            bo1.SetPropertyValue("TestProp", "Value1");
            bo1.SetPropertyValue("TestProp2", "Value2");
            IBusinessObject bo2 = classDef.CreateNewBusinessObject();

            bo2.SetPropertyValue("TestProp", "2Value1");
            bo2.SetPropertyValue("TestProp2", "2Value2");
            col.Add(bo1);
            col.Add(bo2);
            return(col);
        }
コード例 #11
0
        public void Test_Add_PersistedBO()
        {
            //---------------Set up test pack-------------------
            //The persisted business objects should not be added since this is a normal cpCollection which does not
            // modify the added objects alternate key etc unlike the RelatedBusinessObjectCollection
            BusinessObjectCollection <ContactPersonTestBO> cpCol = new BusinessObjectCollection <ContactPersonTestBO>();
            ContactPersonTestBO myBO  = ContactPersonTestBO.CreateSavedContactPerson();
            ContactPersonTestBO myBO2 = ContactPersonTestBO.CreateSavedContactPerson();
            ContactPersonTestBO myBO3 = ContactPersonTestBO.CreateSavedContactPerson();

            _businessObjectCollectionTestHelper.RegisterForAddedEvent(cpCol);

            //-------Assert Preconditions
            Assert.AreEqual(0, cpCol.Count, "Three objects should be in the cpCollection");

            ///---------------Execute Test ----------------------
            cpCol.Add(myBO, myBO2, myBO3);

            //---------------Test Result ----------------------- - Result
            Assert.AreEqual(3, cpCol.Count, "Three objects should be in the copied cpCollection");
            Assert.AreEqual
                (3, cpCol.AddedBusinessObjects.Count,
                "The persisted business objects should not be in the AddedList since this is a normal cpCollection which does not modify the added objects alternate key etc unlike the RelatedBusinessObjectCollection");
            _businessObjectCollectionTestHelper.AssertAddedEventFired();
        }
コード例 #12
0
        public void Test_EditInTextbox_ExistingObject()
        {
            //---------------Set up test pack-------------------
            IEditableGridControl grid = GetControlFactory().CreateEditableGridControl();

            AddControlToForm(grid);
            MyBO.LoadDefaultClassDef();
            IClassDef def = ClassDef.ClassDefs[typeof(MyBO)];

            grid.Initialise(def);
            BusinessObjectCollection <MyBO> col = new BusinessObjectCollection <MyBO>();
            MyBO bo = new MyBO();

            bo.TestProp = "testPropValue";
            col.Add(bo);
            grid.Grid.BusinessObjectCollection = col;
            //--------------Assert PreConditions----------------
            Assert.AreEqual(2, grid.Grid.Rows.Count, "Editable auto adds adding row");

            //---------------Execute Test ----------------------


            const string testvalue = "new test value";

            grid.Grid.Rows[0].Cells[1].Value = testvalue;
            grid.Grid.Rows[1].Selected       = true;
//            grid.ApplyChangesToBusinessObject();

            //---------------Test Result -----------------------
            Assert.AreEqual(testvalue, bo.TestProp);
        }
コード例 #13
0
        public override void Test_SetDateToGridCustomFormat_LoadViaCollection()
        {
            //---------------Set up test pack-------------------
            MyBO.LoadClassDefWithDateTime();
            IDataGridViewColumn             column;
            const string                    requiredFormat = "dd.MMM.yyyy";
            IGridBase                       gridBase       = CreateGridBaseWithDateCustomFormatCol(out column, requiredFormat);
            BusinessObjectCollection <MyBO> col            = new BusinessObjectCollection <MyBO>();
            MyBO         bo           = new MyBO();
            const string dateTimeProp = "TestDateTime";
            DateTime     expectedDate = DateTime.Now;

            bo.SetPropertyValue(dateTimeProp, expectedDate);
            col.Add(bo);
            //--------------Assert PreConditions----------------
            Assert.AreEqual(expectedDate, bo.GetPropertyValue(dateTimeProp));
            Assert.AreEqual(1, gridBase.ColumnCount);
            Assert.AreEqual(dateTimeProp, gridBase.Columns[0].Name);
            Assert.AreEqual(dateTimeProp, gridBase.Columns[0].DataPropertyName);
            //---------------Execute Test ----------------------
            gridBase.BusinessObjectCollection = col;
            //---------------Test Result -----------------------
            IDataGridViewCell dataGridViewCell = gridBase.Rows[0].Cells[0];

            Assert.AreEqual(expectedDate.ToString(requiredFormat), dataGridViewCell.FormattedValue);
        }
コード例 #14
0
        public void TestSerialiseDeserialiseBusinessObjectCollection_EventsAreSetUp()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            BORegistry.DataAccessor = new DataAccessorInMemory();
            Structure.Car.LoadDefaultClassDef();
            OrganisationPerson.LoadDefaultClassDef();
            Person.LoadDefaultClassDef();
            BusinessObjectCollection <Person> originalPeople = new BusinessObjectCollection <Person>();
            Person person1 = Person.CreateSavedPerson();

            originalPeople.Add(person1);

            IFormatter   formatter    = new BinaryFormatter();
            MemoryStream memoryStream = new MemoryStream();

            FixtureEnvironment.ClearBusinessObjectManager();
            bool eventFired = false;

            //---------------Execute Test ----------------------
            formatter.Serialize(memoryStream, originalPeople);
            memoryStream.Seek(0, SeekOrigin.Begin);
            BusinessObjectCollection <Person> deserialisedPeople = (BusinessObjectCollection <Person>)formatter.Deserialize(memoryStream);

            deserialisedPeople.BusinessObjectPropertyUpdated += (sender, args) => eventFired = true;
            deserialisedPeople[0].FirstName = "new firstname";

            //---------------Test Result -----------------------
            Assert.IsTrue(eventFired);
        }
コード例 #15
0
        public void Test_MarkForDelete_Added_RestoreBO_LoadWCriteria()
        {
            //---------------Set up test pack-------------------
            BusinessObjectCollection <ContactPersonTestBO> cpCol = new BusinessObjectCollection <ContactPersonTestBO>();

            cpCol.Load("Surname=cc", "");
            ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson("BB");

            cpCol.Add(myBO);
            myBO.MarkForDelete();
            _businessObjectCollectionTestHelper.RegisterForAddedAndRemovedEvents(cpCol);

            //---------------Assert Precondition----------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInMarkForDeleteAndAddedCollection(cpCol);
            Assert.IsTrue(myBO.Status.IsDirty);

            //---------------Execute Test ----------------------
            myBO.CancelEdits();

            //---------------Test Result -----------------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndAddedCollection(cpCol);
            Assert.IsFalse(myBO.Status.IsDirty);
            _businessObjectCollectionTestHelper.AssertAddedEventFired();
            _businessObjectCollectionTestHelper.AssertRemovedEventNotFired();
        }
コード例 #16
0
        public void Test_AddMethod_WithCollection()
        {
            //---------------Set up test pack-------------------
            //ContactPersonTestBO.LoadDefaultClassDef();
            BusinessObjectCollection <ContactPersonTestBO> cpCol = new BusinessObjectCollection <ContactPersonTestBO>();
            ContactPersonTestBO myBO  = new ContactPersonTestBO();
            ContactPersonTestBO myBO2 = new ContactPersonTestBO();
            ContactPersonTestBO myBO3 = new ContactPersonTestBO();

            cpCol.Add(myBO, myBO2, myBO3);
            //-------Assert Preconditions
            Assert.AreEqual(3, cpCol.Count, "Three objects should be in the cpCollection");
            ///---------------Execute Test ----------------------
            BusinessObjectCollection <ContactPersonTestBO> cpColCopied =
                new BusinessObjectCollection <ContactPersonTestBO>();

            cpColCopied.Add(cpCol);
            //---------------Test Result ----------------------- - Result
            Assert.AreEqual(3, cpColCopied.Count, "Three objects should be in the copied cpCollection");
            Assert.AreEqual(3, cpColCopied.CreatedBusinessObjects.Count);
            Assert.AreEqual(0, cpColCopied.AddedBusinessObjects.Count);
            Assert.AreEqual(myBO, cpColCopied[0], "Added object should be in the copied cpCollection");
            Assert.AreEqual(myBO2, cpColCopied[1], "Added object should be in the copied cpCollection");
            Assert.AreEqual(myBO3, cpColCopied[2], "Added object should be in the copied cpCollection");
        }
コード例 #17
0
        protected static ContactPersonTestBO CreateAddedChild(BusinessObjectCollection <ContactPersonTestBO> cpCol)
        {
            ContactPersonTestBO addedChild = ContactPersonTestBO.CreateSavedContactPerson();

            cpCol.Add(addedChild);
            return(addedChild);
        }
コード例 #18
0
        private static IBusinessObjectCollection GetCol_BO_1ComboBoxItem(IClassDef classDef)
        {
            IBusinessObjectCollection col = new BusinessObjectCollection <BusinessObject>(classDef);
            IBusinessObject           bo1 = classDef.CreateNewBusinessObject();

            bo1.SetPropertyValue("RelatedID", Guid.NewGuid());
            col.Add(bo1);
            return(col);
        }
コード例 #19
0
        private static IBusinessObjectCollection GetCol_BO_1CheckboxItem(IClassDef classDef)
        {
            IBusinessObjectCollection col = new BusinessObjectCollection <BusinessObject>(classDef);
            IBusinessObject           bo1 = classDef.CreateNewBusinessObject();

            bo1.SetPropertyValue("TestProp", true);
            col.Add(bo1);
            return(col);
        }
        public bool SelectAll(BusinessObjectCollection objSource)
        {
            bool       boolStatus = false;
            string     strObject;
            string     strStoredProc;
            SqlCommand command;

            try
            {
                //get the object name
                Type objType = objSource.GetType();
                strObject = objType.FullName.Substring(objType.FullName.IndexOf(".") + 1);
                strObject = strObject.Replace("Collection", "");

                //get the stored procedure name
                strStoredProc  = "app_";
                strStoredProc += strObject;
                strStoredProc += "SelectAll";

                //initialize the command
                command             = new SqlCommand(strStoredProc, dataComponent.Connection);
                command.CommandType = CommandType.StoredProcedure;

                //execute query
                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    BusinessObject newObject = objSource.New();
                    objType = newObject.GetType();

                    for (int intIndex = 0; intIndex < reader.FieldCount; intIndex++)
                    {
                        string       strColName = reader.GetName(intIndex);
                        PropertyInfo field      = objType.GetProperty(strColName);
//JK						field.SetValue( objSource, reader.GetValue( intIndex ), null );
                        field.SetValue(newObject, reader.GetValue(intIndex), null);
                    }

                    objSource.Add(newObject);
                }

                boolStatus = true;
            }
            catch (Exception exception)
            {
                EventLog systemLog = new EventLog();
                systemLog.Source = "IssueTracker";
                systemLog.WriteEntry(exception.Message, EventLogEntryType.Error, 0);
            }
            finally
            {
                dataComponent.Connection.Close();
            }

            return(boolStatus);
        }
コード例 #21
0
        public void TestAddMethod_PersistedObject_IgnoresAddWhenItemAlreadyExists()
        {
            //---------------Set up test pack-------------------
            BusinessObjectCollection <ContactPersonTestBO> cpCol = new BusinessObjectCollection <ContactPersonTestBO>();
            ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson();

            cpCol.Add(myBO);
            _businessObjectCollectionTestHelper.RegisterForAddedEvent(cpCol);

            //---------------Assert Precondition----------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndAddedCollection(cpCol);
            _businessObjectCollectionTestHelper.AssertAddedEventNotFired();
            //---------------Execute Test ----------------------
            cpCol.Add(myBO);

            //---------------Test Result -----------------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndAddedCollection(cpCol);
            _businessObjectCollectionTestHelper.AssertAddedEventNotFired();
        }
コード例 #22
0
        public void TestBusinessObejctAddedToCollection_ShouldAddToItems()
        {
            ClassDef.ClassDefs.Clear();
            IListBox listBox = CreateListBox();
            var      manager = CreateListBoxCollectionManager(listBox);

            MyBO.LoadDefaultClassDef();
            BusinessObjectCollection <MyBO> myBoCol = new BusinessObjectCollection <MyBO>();
            MyBO addedBo = new MyBO();

            myBoCol.Add(new MyBO());
            myBoCol.Add(new MyBO());
            myBoCol.Add(new MyBO());
            manager.SetCollection(myBoCol);
            //---------------Execute Test ----------------------
            manager.Collection.Add(addedBo);
            //---------------Test Result -----------------------
            Assert.AreEqual(4, manager.Control.Items.Count);
        }
コード例 #23
0
        public void Test_EditDataTable_WhenMultipleLevelProp_ShouldEditRelatedBO()
        {
            //---------------Set up test pack-------------------
            RecordingExceptionNotifier recordingExceptionNotifier = new RecordingExceptionNotifier();

            GlobalRegistry.UIExceptionNotifier = recordingExceptionNotifier;
            AddressTestBO.LoadDefaultClassDef();
            ContactPersonTestBO.LoadClassDefWithOrganisationAndAddressRelationships();
            OrganisationTestBO.LoadDefaultClassDef();
            BusinessObjectCollection <AddressTestBO> addresses = new BusinessObjectCollection <AddressTestBO>();

            addresses.Add(new AddressTestBO {
                ContactPersonTestBO = new ContactPersonTestBO()
            });
            addresses.Add(new AddressTestBO {
                ContactPersonTestBO = new ContactPersonTestBO()
            });
            addresses.Add(new AddressTestBO {
                ContactPersonTestBO = new ContactPersonTestBO()
            });

            OrganisationTestBO organisation = new OrganisationTestBO();

            UIGrid       uiGrid       = new UIGrid();
            const string propertyName = "ContactPersonTestBO.OrganisationID";

            uiGrid.Add(new UIGridColumn("Contact Organisation", propertyName, typeof(DataGridViewTextBoxColumn), true, 100, PropAlignment.left, new Hashtable()));

            IDataSetProvider dataSetProvider = CreateDataSetProvider(addresses);
            DataTable        table           = dataSetProvider.GetDataTable(uiGrid);

            //---------------Assert Precondition----------------
            Assert.IsTrue(dataSetProvider is EditableDataSetProvider);
            Assert.AreEqual(3, table.Rows.Count);
            Assert.AreEqual(DBNull.Value, table.Rows[0][propertyName]);
            //---------------Execute Test ----------------------
            table.Rows[0][propertyName] = organisation.OrganisationID;
            //---------------Test Result -----------------------
            Assert.AreEqual(organisation.OrganisationID, table.Rows[0][propertyName]);
            Assert.AreEqual(organisation.OrganisationID, addresses[0].ContactPersonTestBO.OrganisationID);
            recordingExceptionNotifier.RethrowRecordedException();
        }
コード例 #24
0
        public void TestAddMethod_IgnoresAddWhenItemAlreadyExists()
        {
            //---------------Set up test pack-------------------
            MyBO.LoadDefaultClassDef();
            BusinessObjectCollection <MyBO> cpCol = new BusinessObjectCollection <MyBO>();
            MyBO myBO = new MyBO();

            cpCol.Add(myBO);
            _businessObjectCollectionTestHelper.RegisterForAddedEvent(cpCol);
            //---------------Assert Precondition----------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndCreatedCollection(cpCol);
            _businessObjectCollectionTestHelper.AssertAddedEventNotFired();

            //---------------Execute Test ----------------------
            cpCol.Add(myBO);

            //---------------Test Result -----------------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndCreatedCollection(cpCol);
            _businessObjectCollectionTestHelper.AssertAddedEventNotFired();
        }
コード例 #25
0
        public void TestSerialiseDeserialiseBusinessObjectCollection_HavingAllCollections()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            BORegistry.DataAccessor = new DataAccessorInMemory();
            Structure.Car.LoadDefaultClassDef();
            OrganisationPerson.LoadDefaultClassDef();
            Person.LoadDefaultClassDef();
            BusinessObjectCollection <Person> originalPeople = new BusinessObjectCollection <Person>();
            Person persistedPerson = originalPeople.CreateBusinessObject();
            Person deletedPerson   = originalPeople.CreateBusinessObject();
            Person removedPerson   = originalPeople.CreateBusinessObject();

            originalPeople.SaveAll();

            originalPeople.Remove(removedPerson);
            deletedPerson.MarkForDelete();
            Person createdPerson = originalPeople.CreateBusinessObject();
            Person addedPerson   = new Person();

            addedPerson.Save();
            originalPeople.Add(addedPerson);

            IFormatter   formatter    = new BinaryFormatter();
            MemoryStream memoryStream = new MemoryStream();

            FixtureEnvironment.ClearBusinessObjectManager();
            //---------------Assert PreConditions---------------
            Assert.AreEqual(1, originalPeople.MarkedForDeleteBusinessObjects.Count);
            Assert.AreEqual(1, originalPeople.RemovedBusinessObjects.Count);
            Assert.AreEqual(1, originalPeople.AddedBusinessObjects.Count);
            Assert.AreEqual(3, originalPeople.PersistedBusinessObjects.Count);
            Assert.AreEqual(1, originalPeople.CreatedBusinessObjects.Count);
            Assert.AreEqual(3, originalPeople.Count);

            //---------------Execute Test ----------------------
            formatter.Serialize(memoryStream, originalPeople);
            memoryStream.Seek(0, SeekOrigin.Begin);
            BusinessObjectCollection <Person> deserialisedPeople = (BusinessObjectCollection <Person>)formatter.Deserialize(memoryStream);

            //---------------Test Result -----------------------
            Assert.AreEqual(originalPeople.Count, deserialisedPeople.Count);
            Assert.AreEqual(originalPeople.PersistedBusinessObjects.Count, deserialisedPeople.PersistedBusinessObjects.Count);
            Assert.AreEqual(originalPeople.CreatedBusinessObjects.Count, deserialisedPeople.CreatedBusinessObjects.Count);
            Assert.AreEqual(originalPeople.AddedBusinessObjects.Count, deserialisedPeople.AddedBusinessObjects.Count);
            Assert.AreEqual(originalPeople.RemovedBusinessObjects.Count, deserialisedPeople.RemovedBusinessObjects.Count);
            Assert.AreEqual(originalPeople.MarkedForDeleteBusinessObjects.Count, deserialisedPeople.MarkedForDeleteBusinessObjects.Count);

            AssertPersonsAreEqual(deserialisedPeople.MarkedForDeleteBusinessObjects[0], deletedPerson);
            AssertPersonsAreEqual(deserialisedPeople.RemovedBusinessObjects[0], removedPerson);
            AssertPersonsAreEqual(deserialisedPeople.AddedBusinessObjects[0], addedPerson);
            AssertPersonsAreEqual(deserialisedPeople.PersistedBusinessObjects[0], persistedPerson);
            AssertPersonsAreEqual(deserialisedPeople.CreatedBusinessObjects[0], createdPerson);
        }
コード例 #26
0
        public void TestBusinessObjectRemovedFromCollection_ShouldRemoveFromItems()
        {
            ClassDef.ClassDefs.Clear();
            var listBox = CreateListBox();
            var manager = CreateListBoxCollectionManager(listBox);

            MyBO.LoadDefaultClassDef();
            var myBoCol   = new BusinessObjectCollection <MyBO>();
            var removedBo = new MyBO();

            myBoCol.Add(new MyBO());
            myBoCol.Add(removedBo);
            myBoCol.Add(new MyBO());
            manager.BusinessObjectCollection = myBoCol;
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            manager.BusinessObjectCollection.Remove(removedBo);
            //---------------Test Result -----------------------
            Assert.AreEqual(2, manager.Control.Items.Count);
        }
コード例 #27
0
        public void TestSelectedBusinessObject()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            IListBox listBox = CreateListBox();
            var      manager = CreateListBoxCollectionManager(listBox);

            MyBO.LoadDefaultClassDef();
            BusinessObjectCollection <MyBO> myBoCol = new BusinessObjectCollection <MyBO>();
            MyBO selectedBO = new MyBO();

            myBoCol.Add(new MyBO());
            myBoCol.Add(selectedBO);
            myBoCol.Add(new MyBO());
            //---------------Execute Test ----------------------
            manager.SetCollection(myBoCol);
            manager.Control.SelectedIndex = 1;
            //---------------Test Result -----------------------
            Assert.AreEqual(selectedBO, manager.SelectedBusinessObject);
            //---------------Tear down -------------------------
        }
コード例 #28
0
        public void TestSetCollection()
        {
            //---------------Set up test pack-------------------

            MyBO.LoadDefaultClassDef();
            ITabControl            tabControl      = GetControlFactory().CreateTabControl();
            BOColTabControlManager colTabCtlMapper = new BOColTabControlManager(tabControl, GetControlFactory());
            IBusinessObjectControl busControl      = this.CreateBusinessObjectControl();

            colTabCtlMapper.BusinessObjectControl = busControl;
            //---------------Execute Test ----------------------
            BusinessObjectCollection <MyBO> myBoCol = new BusinessObjectCollection <MyBO>();

            myBoCol.Add(new MyBO());
            myBoCol.Add(new MyBO());
            myBoCol.Add(new MyBO());
            colTabCtlMapper.BusinessObjectCollection = myBoCol;
            //---------------Test Result -----------------------
            Assert.AreSame(myBoCol, colTabCtlMapper.BusinessObjectCollection);
            Assert.AreEqual(3, colTabCtlMapper.TabControl.TabPages.Count);
            //---------------Tear down -------------------------
        }
コード例 #29
0
        public void TestAddRowCreatesBusinessObjectThroughCollection()
        {
            SetupTestData();
            //---------------Set up test pack-------------------
            BusinessObjectCollection <MyBO> boCollection = new BusinessObjectCollection <MyBO>();
            MyBO bo = new MyBO();

            bo.SetPropertyValue("TestProp", "bo1prop1");
            bo.SetPropertyValue("TestProp2", "s1");
            bo.Save();
            boCollection.Add(bo);

            MyBO bo2 = new MyBO();

            bo2.SetPropertyValue("TestProp", "bo2prop1");
            bo2.SetPropertyValue("TestProp2", "s2");
            bo2.Save();
            boCollection.Add(bo2);

            _dataSetProvider = new EditableDataSetProvider(boCollection);
            BOMapper mapper = new BOMapper(boCollection.ClassDef.CreateNewBusinessObject());

            itsTable = _dataSetProvider.GetDataTable(mapper.GetUIDef().UIGrid);


            //--------------Assert PreConditions----------------
            Assert.AreEqual(2, boCollection.Count);
            Assert.AreEqual(0, boCollection.CreatedBusinessObjects.Count, "Should be no created items to start");

            //---------------Execute Test ----------------------
            itsTable.Rows.Add(new object[] { null, "bo3prop1", "bo3prop2" });

            //---------------Test Result -----------------------
            Assert.AreEqual
                (1, boCollection.CreatedBusinessObjects.Count,
                "Adding a row to the table should use the collection to create the object");
            //Assert.AreEqual(2, boCollection.Count, "Adding a row to the table should not add a bo to the main collection");
            Assert.AreEqual(3, boCollection.Count, "Adding a row to the table should add a bo to the main collection");
        }
コード例 #30
0
        public void TestAddBoToCollection()
        {
            ListView listView = CreateListView();
            ListViewCollectionManager       controller = new ListViewCollectionManager(listView);
            BusinessObjectCollection <MyBO> col        = GetColWith3Items();

            controller.SetCollection(col);
            //---------------Assert Precondition----------------
            Assert.AreEqual(3, listView.Items.Count);
            //---------------Execute Test ----------------------
            col.Add(new MyBO());
            //---------------Test Result -----------------------
            Assert.AreEqual(4, listView.Items.Count);
        }
コード例 #31
0
        public void Test_MarkForDelete_Added_AddBo()
        {
            //---------------Set up test pack-------------------
            BusinessObjectCollection <ContactPersonTestBO> cpCol = new BusinessObjectCollection <ContactPersonTestBO>();

            ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson("BB");

            cpCol.Add(myBO);
            myBO.MarkForDelete();
            _businessObjectCollectionTestHelper.RegisterForAddedAndRemovedEvents(cpCol);

            //---------------Assert Precondition----------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInMarkForDeleteAndAddedCollection(cpCol);
            Assert.IsTrue(myBO.Status.IsDirty);

            //---------------Execute Test ----------------------
            cpCol.Add(myBO);

            //---------------Test Result -----------------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInMarkForDeleteAndAddedCollection(cpCol);
            Assert.IsTrue(myBO.Status.IsDirty);
            _businessObjectCollectionTestHelper.AssertAddedAndRemovedEventsNotFired();
        }
コード例 #32
0
        public void TestInitGrid_UIDef_DateFormat_FormatsDateColumn()
        {
            //---------------Set up test pack-------------------
            IClassDef            classDef    = MyBO.LoadClassDefWithDateTimeParameterFormat();
            IReadOnlyGridControl grid        = CreateReadOnlyGridControl();
            IGridInitialiser     initialiser = new GridInitialiser(grid, GetControlFactory());
            IUIDef  uiDef     = classDef.UIDefCol["default"];
            IUIGrid uiGridDef = uiDef.UIGrid;

            AddControlToForm(grid);
            GlobalUIRegistry.DateDisplaySettings = new DateDisplaySettings();
            GlobalUIRegistry.DateDisplaySettings.GridDateFormat = "dd MMM yyyy";
            //--------------Assert PreConditions----------------
            const string formattedPropertyName = "TestDateTimeFormat";

            Assert.IsNotNull(uiGridDef[formattedPropertyName]);
            Assert.IsNotNull(uiGridDef["TestDateTimeNoFormat"]);
            Assert.IsNotNull(uiGridDef["TestDateTime"]);

            Assert.IsNull(uiGridDef["TestDateTimeNoFormat"].GetParameterValue("dateFormat"));
            Assert.IsNull(uiGridDef["TestDateTime"].GetParameterValue("dateFormat"));
            object       dateFormatObject    = uiGridDef[formattedPropertyName].GetParameterValue("dateFormat");
            string       dateFormatParameter = dateFormatObject.ToString();
            const string expectedFormat      = "dd.MMM.yyyy";

            Assert.AreEqual(expectedFormat, dateFormatParameter);

            MyBO     myBo            = new MyBO();
            DateTime currentDateTime = DateTime.Now;

            myBo.SetPropertyValue(formattedPropertyName, currentDateTime);
            BusinessObjectCollection <MyBO> col = new BusinessObjectCollection <MyBO>();

            col.Add(myBo);

            //---------------Execute Test ----------------------
            initialiser.InitialiseGrid(classDef);
            grid.BusinessObjectCollection = col;

            //---------------Test Result -----------------------
            Assert.AreEqual(1, col.Count);
            Assert.AreEqual(1, grid.Grid.Rows.Count);
            IDataGridViewCell dataGridViewCell = grid.Grid.Rows[0].Cells[formattedPropertyName];

            //((DataGridViewCellVWG) dataGridViewCell).DataGridViewCell.HasStyle = false;
            Assert.AreSame(typeof(DateTime), dataGridViewCell.ValueType);
            Assert.AreEqual(currentDateTime.ToString(expectedFormat), dataGridViewCell.FormattedValue);

            //---------------Tear Down -------------------------
        }
コード例 #33
0
        public void TestAddRowCreatesBusinessObjectThroughCollection()
        {
            SetupTestData();
            //---------------Set up test pack-------------------
            BusinessObjectCollection<MyBO> boCollection = new BusinessObjectCollection<MyBO>();
            MyBO bo = new MyBO();
            bo.SetPropertyValue("TestProp", "bo1prop1");
            bo.SetPropertyValue("TestProp2", "s1");
            bo.Save();
            boCollection.Add(bo);

            MyBO bo2 = new MyBO();
            bo2.SetPropertyValue("TestProp", "bo2prop1");
            bo2.SetPropertyValue("TestProp2", "s2");
            bo2.Save();
            boCollection.Add(bo2);

            _dataSetProvider = new EditableDataSetProvider(boCollection);
            BOMapper mapper = new BOMapper(boCollection.ClassDef.CreateNewBusinessObject());

            itsTable = _dataSetProvider.GetDataTable(mapper.GetUIDef().UIGrid);


            //--------------Assert PreConditions----------------            
            Assert.AreEqual(2, boCollection.Count);
            Assert.AreEqual(0, boCollection.CreatedBusinessObjects.Count, "Should be no created items to start");

            //---------------Execute Test ----------------------
            itsTable.Rows.Add(new object[] {null, "bo3prop1", "bo3prop2"});

            //---------------Test Result -----------------------
            Assert.AreEqual
                (1, boCollection.CreatedBusinessObjects.Count,
                 "Adding a row to the table should use the collection to create the object");
            //Assert.AreEqual(2, boCollection.Count, "Adding a row to the table should not add a bo to the main collection");
            Assert.AreEqual(3, boCollection.Count, "Adding a row to the table should add a bo to the main collection");
        }
コード例 #34
0
 public void Test_AddMethod()
 {
     //---------------Set up test pack-------------------
     //ContactPersonTestBO.LoadDefaultClassDef();
     BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
     ContactPersonTestBO myBO = new ContactPersonTestBO();
     _businessObjectCollectionTestHelper.RegisterForAddedEvent(cpCol);
     //---------------Assert Precondition----------------
     Assert.AreEqual(0, cpCol.Count);
     Assert.AreEqual(0, cpCol.AddedBusinessObjects.Count);
     _businessObjectCollectionTestHelper.AssertAddedEventNotFired();
     //---------------Execute Test ----------------------
     cpCol.Add(myBO);
     //---------------Test Result -----------------------
     Assert.AreEqual(1, cpCol.Count, "One object should be in the cpCollection");
     BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndCreatedCollection(cpCol);
     _businessObjectCollectionTestHelper.AssertAddedEventFired();
     Assert.AreEqual(myBO, cpCol[0], "Added object should be in the cpCollection");
 }
コード例 #35
0
        public void TestCreateTestListBoxCollectionController()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            MyBO.LoadClassDefWithBoolean();
            BusinessObjectCollection<MyBO> myBOs = new BusinessObjectCollection<MyBO>();
            MyBO myBO1 = new MyBO();
            MyBO myBO2 = new MyBO();
            myBOs.Add(myBO1, myBO2);
            IListBox cmb = CreateListBox();
            var selector = CreateListBoxCollectionManager(cmb);
            //---------------Verify test pack-------------------
            //---------------Execute Test ----------------------

            selector.SetCollection(myBOs);
            //---------------Verify Result -----------------------
            Assert.AreEqual(myBOs, selector.Collection);
            Assert.AreSame(cmb, selector.Control);
            //---------------Tear Down -------------------------   
        }
コード例 #36
0
        public void TestInitGrid_UIDef_CurrencyFormat_WhenVirtualProp_ShouldFormatColumn()
        {
            //---------------Set up test pack-------------------
            IClassDef classDef = MyBO.LoadClassDefWithCurrencyParameterFormat();
            IReadOnlyGridControl grid = CreateReadOnlyGridControl();
            IGridInitialiser initialiser = new GridInitialiser(grid, GetControlFactory());
            IUIDef uiDef = classDef.UIDefCol["default"];
            IUIGrid uiGridDef = uiDef.UIGrid;
            AddControlToForm(grid);

            //--------------Assert PreConditions----------------            
            const string formattedPropertyName = "TestCurrencyFormat";
            Assert.IsNotNull(uiGridDef[formattedPropertyName]);
            Assert.IsNotNull(uiGridDef[formattedPropertyName].GetParameterValue("currencyFormat"));

            const string unformattedPropName = "TestCurrencyNoFormat";
            Assert.IsNotNull(uiGridDef[unformattedPropName]);
            Assert.IsNull(uiGridDef[unformattedPropName].GetParameterValue("currencyFormat"));

            object currencyFormat = uiGridDef[formattedPropertyName].GetParameterValue("currencyFormat");
            string currencyFormatParameter = currencyFormat.ToString();
            const string expectedFormat = "### ###.##";
            Assert.AreEqual(expectedFormat, currencyFormatParameter);

            MyBO myBo = new MyBO();
            const double currencyValue = 222222.55555d;
            myBo.SetPropertyValue(formattedPropertyName, currencyValue);
            BusinessObjectCollection<MyBO> col = new BusinessObjectCollection<MyBO>();
            col.Add(myBo);

            //---------------Execute Test ----------------------
            initialiser.InitialiseGrid(classDef);
            grid.BusinessObjectCollection = col;

            //---------------Test Result -----------------------
            Assert.AreEqual(1, col.Count);
            Assert.AreEqual(1, grid.Grid.Rows.Count);
            IDataGridViewCell dataGridViewCell = grid.Grid.Rows[0].Cells[formattedPropertyName];
            //((DataGridViewCellVWG) dataGridViewCell).DataGridViewCell.HasStyle = false;
            Assert.AreSame(typeof(Double), dataGridViewCell.ValueType);
            Assert.AreEqual(currencyValue.ToString(expectedFormat), dataGridViewCell.FormattedValue);
        }
コード例 #37
0
        public void Test_EditDataTable_WhenVirtualProp_ShouldEditRelatedVirtualProp()
        {
            //---------------Set up test pack-------------------
            RecordingExceptionNotifier recordingExceptionNotifier = new RecordingExceptionNotifier();
            GlobalRegistry.UIExceptionNotifier = recordingExceptionNotifier;
            AddressTestBO.LoadDefaultClassDef();
            var contactPersonClassDef = ContactPersonTestBO.LoadClassDefWithOrganisationAndAddressRelationships();
            OrganisationTestBO.LoadDefaultClassDef();
            BusinessObjectCollection<ContactPersonTestBO> contactPersonTestBOS = new BusinessObjectCollection<ContactPersonTestBO>();
            contactPersonTestBOS.Add(new ContactPersonTestBO(), new ContactPersonTestBO(), new ContactPersonTestBO());

            OrganisationTestBO organisation = new OrganisationTestBO();

            UIGrid uiGrid = new UIGrid();
            new UIDef("fdafdas", new UIForm(), uiGrid) { ClassDef = contactPersonClassDef };
            const string propertyName = "-Organisation-";
            uiGrid.Add(new UIGridColumn("Contact Organisation", propertyName, typeof(DataGridViewTextBoxColumn), true, 100, PropAlignment.left, new Hashtable()));

            IDataSetProvider dataSetProvider = CreateDataSetProvider(contactPersonTestBOS);
            DataTable table = dataSetProvider.GetDataTable(uiGrid);

            //---------------Assert Precondition----------------
            Assert.IsTrue(dataSetProvider is EditableDataSetProvider);
            Assert.AreEqual(3, table.Rows.Count);
            Assert.AreEqual(DBNull.Value, table.Rows[0][propertyName]);
            Assert.AreEqual(null, contactPersonTestBOS[0].Organisation);
            //---------------Execute Test ----------------------
            table.Rows[0][propertyName] = organisation;
            //---------------Test Result -----------------------
            Assert.AreSame(organisation, table.Rows[0][propertyName]);
            Assert.AreSame(organisation, contactPersonTestBOS[0].Organisation);
            recordingExceptionNotifier.RethrowRecordedException();
        }
コード例 #38
0
 public void Test_AddMethod_WithParamArray()
 {
     //---------------Set up test pack-------------------
     //ContactPersonTestBO.LoadDefaultClassDef();
     BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
     ContactPersonTestBO myBO = new ContactPersonTestBO();
     ContactPersonTestBO myBO2 = new ContactPersonTestBO();
     ContactPersonTestBO myBO3 = new ContactPersonTestBO();
     //---------------Execute Test ----------------------
     cpCol.Add(myBO, myBO2, myBO3);
     //---------------Test Result -----------------------
     Assert.AreEqual(3, cpCol.Count, "Three objects should be in the cpCollection");
     Assert.AreEqual(myBO, cpCol[0], "Added object should be in the cpCollection");
     Assert.AreEqual(myBO2, cpCol[1], "Added object should be in the cpCollection");
     Assert.AreEqual(myBO3, cpCol[2], "Added object should be in the cpCollection");
 }
コード例 #39
0
        public void TestAddMethod_IgnoresAddWhenItemAlreadyExists()
        {
            //---------------Set up test pack-------------------
            MyBO.LoadDefaultClassDef();
            BusinessObjectCollection<MyBO> cpCol = new BusinessObjectCollection<MyBO>();
            MyBO myBO = new MyBO();
            cpCol.Add(myBO);
            _businessObjectCollectionTestHelper.RegisterForAddedEvent(cpCol);
            //---------------Assert Precondition----------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndCreatedCollection(cpCol);
            _businessObjectCollectionTestHelper.AssertAddedEventNotFired();

            //---------------Execute Test ----------------------
            cpCol.Add(myBO);

            //---------------Test Result -----------------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndCreatedCollection(cpCol);
            _businessObjectCollectionTestHelper.AssertAddedEventNotFired();
        }
コード例 #40
0
        public void TestAddMethod_RemoveAddedBusinessObject()
        {
            //---------------Set up test pack-------------------
            BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
            ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson();
            cpCol.Add(myBO);
            _businessObjectCollectionTestHelper.RegisterForAddedAndRemovedEvents(cpCol);

            //---------------Assert Precondition----------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndAddedCollection(cpCol);
            Assert.IsFalse(myBO.Status.IsDirty);
            _businessObjectCollectionTestHelper.AssertAddedAndRemovedEventsNotFired();
            //---------------Execute Test ----------------------
            cpCol.Remove(myBO);

            //---------------Test Result -----------------------
            BusinessObjectCollectionTestHelper.AssertAllCollectionsHaveNoItems(cpCol);
            Assert.IsFalse(myBO.Status.IsDirty);
            _businessObjectCollectionTestHelper.AssertRemovedEventFired();
            _businessObjectCollectionTestHelper.AssertAddedEventNotFired();
        }
コード例 #41
0
        public void Test_LoadTreeView_WithRelationship_OneChild_Expanded()
        {
            //---------------Set up test pack-------------------
            ITreeView treeView = GlobalUIRegistry.ControlFactory.CreateTreeView();
            TreeViewController treeViewController = new TreeViewController(treeView);
            OrganisationTestBO organisation = OrganisationTestBO.CreateSavedOrganisation();
            ContactPersonTestBO contactPerson = CreateUnsavedContactPerson(organisation);

            IBusinessObjectCollection organisations = new BusinessObjectCollection<OrganisationTestBO>();
            organisations.Add(organisation);
            //-------------Assert Preconditions -------------
            Assert.AreEqual(1, organisations.Count);
            Assert.AreEqual(0, treeView.Nodes.Count);
            //---------------Execute Test ----------------------
            treeViewController.LoadTreeView(organisations, 2);
            //---------------Test Result -----------------------
            Assert.AreEqual(1, treeView.Nodes.Count);
            ITreeNode node = treeView.Nodes[0];
            Assert.AreEqual(organisation.ToString(), node.Text);
            Assert.AreEqual(1, node.Nodes.Count);
            ITreeNode relationshipNode = node.Nodes[0];
            Assert.AreEqual("ContactPeople", relationshipNode.Text);
            Assert.AreEqual(1, relationshipNode.Nodes.Count);
            ITreeNode childNode = relationshipNode.Nodes[0];
            Assert.AreEqual(contactPerson.ToString(), childNode.Text);
        }
コード例 #42
0
        public void Test_MarkForDelete_Added_boSave()
        {
            //---------------Set up test pack-------------------
            BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();

            ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson("BB");
            cpCol.Add(myBO);
            myBO.MarkForDelete();

            //---------------Assert Precondition----------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInMarkForDeleteAndAddedCollection(cpCol);
            Assert.IsTrue(myBO.Status.IsDirty);

            //---------------Execute Test ----------------------
            myBO.Save();

            //---------------Test Result -----------------------
            BusinessObjectCollectionTestHelper.AssertAllCollectionsHaveNoItems(cpCol);
            Assert.IsFalse(myBO.Status.IsDirty);
        }
コード例 #43
0
        public void Test_MarkForDelete_Added_AddBo()
        {
            //---------------Set up test pack-------------------
            BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();

            ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson("BB");
            cpCol.Add(myBO);
            myBO.MarkForDelete();
            _businessObjectCollectionTestHelper.RegisterForAddedAndRemovedEvents(cpCol);

            //---------------Assert Precondition----------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInMarkForDeleteAndAddedCollection(cpCol);
            Assert.IsTrue(myBO.Status.IsDirty);

            //---------------Execute Test ----------------------
            cpCol.Add(myBO);

            //---------------Test Result -----------------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInMarkForDeleteAndAddedCollection(cpCol);
            Assert.IsTrue(myBO.Status.IsDirty);
            _businessObjectCollectionTestHelper.AssertAddedAndRemovedEventsNotFired();
        }
コード例 #44
0
        public void Test_MarkForDelete_Added_RestoreBO_LoadWCriteria()
        {
            //---------------Set up test pack-------------------
            BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
            cpCol.Load("Surname=cc", "");
            ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson("BB");
            cpCol.Add(myBO);
            myBO.MarkForDelete();
            _businessObjectCollectionTestHelper.RegisterForAddedAndRemovedEvents(cpCol);

            //---------------Assert Precondition----------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInMarkForDeleteAndAddedCollection(cpCol);
            Assert.IsTrue(myBO.Status.IsDirty);

            //---------------Execute Test ----------------------
            myBO.CancelEdits();

            //---------------Test Result -----------------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndAddedCollection(cpCol);
            Assert.IsFalse(myBO.Status.IsDirty);
            _businessObjectCollectionTestHelper.AssertAddedEventFired();
            _businessObjectCollectionTestHelper.AssertRemovedEventNotFired();
        }
コード例 #45
0
        public void Test_MarkForDelete_Added_RefreshAll()
        {
            //---------------Set up test pack-------------------
            ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson();
            BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
            cpCol.Load(new Criteria("Surname", Criteria.ComparisonOp.Equals, TestUtil.GetRandomString()), "" );
            cpCol.Add(myBO);
            myBO.MarkForDelete();
            _businessObjectCollectionTestHelper.RegisterForAddedAndRemovedEvents(cpCol);

            //---------------Assert Precondition----------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInMarkForDeleteAndAddedCollection(cpCol);
            Assert.IsTrue(myBO.Status.IsDirty);
            _businessObjectCollectionTestHelper.AssertAddedAndRemovedEventsNotFired();
            //---------------Execute Test ----------------------
            cpCol.Refresh();

            //---------------Test Result -----------------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInMarkForDeleteAndAddedCollection(cpCol);
            Assert.IsTrue(myBO.Status.IsDirty);
            _businessObjectCollectionTestHelper.AssertAddedAndRemovedEventsNotFired();
        }
コード例 #46
0
        public void TestAddMethod_SaveBusinessObject()
        {
            //---------------Set up test pack-------------------
            BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
            ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson();
            cpCol.Add(myBO);
            myBO.Surname = TestUtil.GetRandomString();
            _businessObjectCollectionTestHelper.RegisterForAddedEvent(cpCol);
            //---------------Assert Precondition----------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndAddedCollection(cpCol);
            _businessObjectCollectionTestHelper.AssertAddedEventNotFired();

            //---------------Execute Test ----------------------
            myBO.Save();

            //---------------Test Result -----------------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentPersistedAndAddedCollection(cpCol);
            _businessObjectCollectionTestHelper.AssertAddedEventNotFired();
        }
コード例 #47
0
        public void TestAddMethod_PersistedObject_IgnoresAddWhenItemAlreadyExists()
        {
            //---------------Set up test pack-------------------
            BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
            ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson();
            cpCol.Add(myBO);
            _businessObjectCollectionTestHelper.RegisterForAddedEvent(cpCol);

            //---------------Assert Precondition----------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndAddedCollection(cpCol);
            _businessObjectCollectionTestHelper.AssertAddedEventNotFired();
            //---------------Execute Test ----------------------
            cpCol.Add(myBO);

            //---------------Test Result -----------------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndAddedCollection(cpCol);
            _businessObjectCollectionTestHelper.AssertAddedEventNotFired();
        }
コード例 #48
0
        public void TestSerialiseDeserialiseBusinessObjectCollection_EventsAreSetUp()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            BORegistry.DataAccessor = new DataAccessorInMemory();
            Structure.Car.LoadDefaultClassDef();
            OrganisationPerson.LoadDefaultClassDef();
            Person.LoadDefaultClassDef();
            BusinessObjectCollection<Person> originalPeople = new BusinessObjectCollection<Person>();
            Person person1 = Person.CreateSavedPerson();
            originalPeople.Add(person1);

            IFormatter formatter = new BinaryFormatter();
            MemoryStream memoryStream = new MemoryStream();
            FixtureEnvironment.ClearBusinessObjectManager();
            bool eventFired = false;

            //---------------Execute Test ----------------------
            formatter.Serialize(memoryStream, originalPeople);
            memoryStream.Seek(0, SeekOrigin.Begin);
            BusinessObjectCollection<Person> deserialisedPeople = (BusinessObjectCollection<Person>)formatter.Deserialize(memoryStream);
            deserialisedPeople.BusinessObjectPropertyUpdated += (sender, args) => eventFired = true;
            deserialisedPeople[0].FirstName = "new firstname";

            //---------------Test Result -----------------------
            Assert.IsTrue(eventFired);
   
        }
コード例 #49
0
        public void Test_Add_NewBO_AddsToCreatedCollection()
        {
            //---------------Set up test pack-------------------
            //ContactPersonTestBO.LoadDefaultClassDef();
            BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
            ContactPersonTestBO newCP = ContactPersonTestBO.CreateUnsavedContactPerson
                (BOTestUtils.RandomString, BOTestUtils.RandomString);
            _businessObjectCollectionTestHelper.RegisterForAddedEvent(cpCol);

            //---------------Assert Precondition----------------
            Assert.AreEqual(0, cpCol.Count);
            Assert.AreEqual(0, cpCol.CreatedBusinessObjects.Count);

            //---------------Execute Test ----------------------
            cpCol.Add(newCP);

            //---------------Test Result -----------------------
            Assert.AreEqual(1, cpCol.Count);
            Assert.AreEqual(1, cpCol.CreatedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.AddedBusinessObjects.Count);
            Assert.Contains(newCP, cpCol);
            _businessObjectCollectionTestHelper.AssertAddedEventFired();
        }
コード例 #50
0
        public void Test_Add_PersistedBO()
        {
            //---------------Set up test pack-------------------
            //The persisted business objects should not be added since this is a normal cpCollection which does not 
            // modify the added objects alternate key etc unlike the RelatedBusinessObjectCollection
            BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
            ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson();
            ContactPersonTestBO myBO2 = ContactPersonTestBO.CreateSavedContactPerson();
            ContactPersonTestBO myBO3 = ContactPersonTestBO.CreateSavedContactPerson();
            _businessObjectCollectionTestHelper.RegisterForAddedEvent(cpCol);

            //-------Assert Preconditions
            Assert.AreEqual(0, cpCol.Count, "Three objects should be in the cpCollection");

            ///---------------Execute Test ----------------------
            cpCol.Add(myBO, myBO2, myBO3);

            //---------------Test Result ----------------------- - Result
            Assert.AreEqual(3, cpCol.Count, "Three objects should be in the copied cpCollection");
            Assert.AreEqual
                (3, cpCol.AddedBusinessObjects.Count,
                 "The persisted business objects should not be in the AddedList since this is a normal cpCollection which does not modify the added objects alternate key etc unlike the RelatedBusinessObjectCollection");
            _businessObjectCollectionTestHelper.AssertAddedEventFired();
        }
コード例 #51
0
            Test_BusinessObjectCollection_WhenSet_WithNewCollection_WhenItemAlreadySelected_AndDifferentMatchInNewList_ShouldSelectNewMatch
            ()
        {
            //---------------Set up test pack-------------------
            IComboBox cmbox = GetControlFactory().CreateComboBox();
            const string propName = "SampleText";
            var mapper = CreateCollectionComboBoxMapper(cmbox, propName);
            mapper.OwningBoPropertyName = "CarRegNo";

            Car car1;
            Car car2;
            mapper.BusinessObjectCollection = GetCollectionWithTwoCars(out car1, out car2);
            string carRegNo = "MySelectedRegNo " + TestUtil.GetRandomString().Substring(0, 4);
            car1.CarRegNo = carRegNo;
            car2.CarRegNo = TestUtil.GetRandomString();
            Sample sample = new Sample {SampleText = carRegNo};
            BusinessObjectCollection<Car> newCol = new BusinessObjectCollection<Car>();
            Car car3 = new Car {CarRegNo = carRegNo};
            newCol.Add(car2, car3);
            mapper.BusinessObject = sample;
            //---------------Assert Precondition----------------
            Assert.AreEqual(2, mapper.BusinessObjectCollection.Count);
            Assert.AreEqual(3, cmbox.Items.Count);
            Assert.AreEqual(car1, cmbox.SelectedItem, "Combo Box selected item should be set.");
            Assert.AreEqual("CarRegNo", mapper.OwningBoPropertyName);
            //---------------Execute Test ----------------------
            mapper.BusinessObjectCollection = newCol;
            //---------------Test Result -----------------------
            Assert.IsNotNull(cmbox.SelectedItem);
            Assert.AreEqual(car3, cmbox.SelectedItem, "Combo Box selected item should now be the new match.");
            Assert.AreSame(carRegNo, sample.SampleText);
        }
コード例 #52
0
        public void TestSetCollection()
        {
            //---------------Set up test pack-------------------

            MyBO.LoadDefaultClassDef();
            ITabControl tabControl = GetControlFactory().CreateTabControl();
            BOColTabControlManager colTabCtlMapper = new BOColTabControlManager(tabControl, GetControlFactory());
            IBusinessObjectControl busControl = this.CreateBusinessObjectControl();
            colTabCtlMapper.BusinessObjectControl = busControl;
            //---------------Execute Test ----------------------
            BusinessObjectCollection<MyBO> myBoCol = new BusinessObjectCollection<MyBO>();
            myBoCol.Add(new MyBO());
            myBoCol.Add(new MyBO());
            myBoCol.Add(new MyBO());
            colTabCtlMapper.BusinessObjectCollection = myBoCol;
            //---------------Test Result -----------------------
            Assert.AreSame(myBoCol, colTabCtlMapper.BusinessObjectCollection);
            Assert.AreEqual(3, colTabCtlMapper.TabControl.TabPages.Count);
            //---------------Tear down -------------------------
        }
コード例 #53
0
        public void TestSerialiseDeserialiseBusinessObjectCollection()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            BORegistry.DataAccessor = new DataAccessorInMemory();
            Structure.Car.LoadDefaultClassDef();
            OrganisationPerson.LoadDefaultClassDef();
            Person.LoadDefaultClassDef();
            BusinessObjectCollection<Person> originalPeople = new BusinessObjectCollection<Person>();
            Person person1 = Person.CreateSavedPerson();
            originalPeople.Add(person1);
            Person person2 = Person.CreateSavedPerson();
            originalPeople.Add(person2);
            Person person3 = Person.CreateSavedPerson();
            originalPeople.Add(person3);
            
            IFormatter formatter = new BinaryFormatter();
            MemoryStream memoryStream = new MemoryStream();
            FixtureEnvironment.ClearBusinessObjectManager();

            //---------------Execute Test ----------------------
            formatter.Serialize(memoryStream, originalPeople);
            memoryStream.Seek(0, SeekOrigin.Begin);
            BusinessObjectCollection<Person> deserialisedPeople = (BusinessObjectCollection<Person>)formatter.Deserialize(memoryStream);

            //---------------Test Result -----------------------
            Assert.AreEqual(originalPeople.Count, deserialisedPeople.Count);

            Assert.AreNotSame(originalPeople,deserialisedPeople);
            AssertPersonsAreEqual(deserialisedPeople[0], originalPeople[0]);
            AssertPersonsAreEqual(deserialisedPeople[1], originalPeople[1]);
            AssertPersonsAreEqual(deserialisedPeople[2], originalPeople[2]);
        }
コード例 #54
0
 //TODO Mark 07 Aug 2009: NNB Review this - I don't think that this is the action you want because it could have side effects when creating a new BO
 public virtual void Test_AddBOToCol_WhenNullOrEmptyToString_ShouldRaiseError()
 {
     //---------------Set up test pack-------------------
     IComboBox cmbox = CreateComboBox();
     RelationshipComboBoxMapper mapper1 = GetMapper(cmbox);
     BusinessObjectCollection<ContactPersonTestBO> boCol = new BusinessObjectCollection<ContactPersonTestBO> { new ContactPersonTestBO() };
     mapper1.BusinessObjectCollection = boCol;
     RelationshipComboBoxMapper mapper = mapper1;
     ContactPersonTestBO newBO = new ContactPersonTestBO { Surname = "" };
     //---------------Assert Precondition----------------
     Assert.AreEqual(1, boCol.Count);
     Assert.AreEqual(2, mapper.Control.Items.Count);
     Assert.IsNull(newBO.ToString());
     //---------------Execute Test ----------------------
     try
     {
         boCol.Add(newBO);
         Assert.Fail("expected HabaneroDeveloperException");
     }
     //---------------Test Result -----------------------
     catch (HabaneroDeveloperException ex)
     {
         string message = string.Format("Cannot add a business object of type '{0}' "
                                        + "to the 'ComboBoxCollectionSelector' if its ToString is null or zero length"
                                        , newBO.ClassDef.ClassName);
         StringAssert.Contains(message, ex.Message);
     }
 }
コード例 #55
0
        public void TestSerialiseDeserialiseBusinessObjectCollection_HavingAllCollections()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            BORegistry.DataAccessor = new DataAccessorInMemory();
            Structure.Car.LoadDefaultClassDef();
            OrganisationPerson.LoadDefaultClassDef();
            Person.LoadDefaultClassDef();
            BusinessObjectCollection<Person> originalPeople = new BusinessObjectCollection<Person>();
            Person persistedPerson = originalPeople.CreateBusinessObject();
            Person deletedPerson = originalPeople.CreateBusinessObject();
            Person removedPerson = originalPeople.CreateBusinessObject();
            originalPeople.SaveAll();

            originalPeople.Remove(removedPerson);
            deletedPerson.MarkForDelete();
            Person createdPerson = originalPeople.CreateBusinessObject();
            Person addedPerson = new Person();
            addedPerson.Save();
            originalPeople.Add(addedPerson);

            IFormatter formatter = new BinaryFormatter();
            MemoryStream memoryStream = new MemoryStream();
            FixtureEnvironment.ClearBusinessObjectManager();
            //---------------Assert PreConditions---------------       
            Assert.AreEqual(1, originalPeople.MarkedForDeleteBusinessObjects.Count);
            Assert.AreEqual(1, originalPeople.RemovedBusinessObjects.Count);
            Assert.AreEqual(1, originalPeople.AddedBusinessObjects.Count);
            Assert.AreEqual(3, originalPeople.PersistedBusinessObjects.Count);
            Assert.AreEqual(1, originalPeople.CreatedBusinessObjects.Count);
            Assert.AreEqual(3, originalPeople.Count);

            //---------------Execute Test ----------------------
            formatter.Serialize(memoryStream, originalPeople);
            memoryStream.Seek(0, SeekOrigin.Begin);
            BusinessObjectCollection<Person> deserialisedPeople = (BusinessObjectCollection<Person>)formatter.Deserialize(memoryStream);

            //---------------Test Result -----------------------
            Assert.AreEqual(originalPeople.Count, deserialisedPeople.Count);
            Assert.AreEqual(originalPeople.PersistedBusinessObjects.Count, deserialisedPeople.PersistedBusinessObjects.Count);
            Assert.AreEqual(originalPeople.CreatedBusinessObjects.Count, deserialisedPeople.CreatedBusinessObjects.Count);
            Assert.AreEqual(originalPeople.AddedBusinessObjects.Count, deserialisedPeople.AddedBusinessObjects.Count);
            Assert.AreEqual(originalPeople.RemovedBusinessObjects.Count, deserialisedPeople.RemovedBusinessObjects.Count);
            Assert.AreEqual(originalPeople.MarkedForDeleteBusinessObjects.Count, deserialisedPeople.MarkedForDeleteBusinessObjects.Count);

            AssertPersonsAreEqual(deserialisedPeople.MarkedForDeleteBusinessObjects[0], deletedPerson);
            AssertPersonsAreEqual(deserialisedPeople.RemovedBusinessObjects[0], removedPerson);
            AssertPersonsAreEqual(deserialisedPeople.AddedBusinessObjects[0], addedPerson);
            AssertPersonsAreEqual(deserialisedPeople.PersistedBusinessObjects[0], persistedPerson);
            AssertPersonsAreEqual(deserialisedPeople.CreatedBusinessObjects[0], createdPerson);

        }
コード例 #56
0
 public void Test_AddMethod_WithCollection()
 {
     //---------------Set up test pack-------------------
     //ContactPersonTestBO.LoadDefaultClassDef();
     BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
     ContactPersonTestBO myBO = new ContactPersonTestBO();
     ContactPersonTestBO myBO2 = new ContactPersonTestBO();
     ContactPersonTestBO myBO3 = new ContactPersonTestBO();
     cpCol.Add(myBO, myBO2, myBO3);
     //-------Assert Preconditions
     Assert.AreEqual(3, cpCol.Count, "Three objects should be in the cpCollection");
     ///---------------Execute Test ----------------------
     BusinessObjectCollection<ContactPersonTestBO> cpColCopied =
         new BusinessObjectCollection<ContactPersonTestBO>();
     cpColCopied.Add(cpCol);
     //---------------Test Result ----------------------- - Result
     Assert.AreEqual(3, cpColCopied.Count, "Three objects should be in the copied cpCollection");
     Assert.AreEqual(3, cpColCopied.CreatedBusinessObjects.Count);
     Assert.AreEqual(0, cpColCopied.AddedBusinessObjects.Count);
     Assert.AreEqual(myBO, cpColCopied[0], "Added object should be in the copied cpCollection");
     Assert.AreEqual(myBO2, cpColCopied[1], "Added object should be in the copied cpCollection");
     Assert.AreEqual(myBO3, cpColCopied[2], "Added object should be in the copied cpCollection");
 }
コード例 #57
0
        public void TestAddMethod_RestoreBusinessObject()
        {
            //---------------Set up test pack-------------------
            BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
            ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson();
            cpCol.Add(myBO);
            myBO.Surname = TestUtil.GetRandomString();
            _businessObjectCollectionTestHelper.RegisterForAddedAndRemovedEvents(cpCol);

            //---------------Assert Precondition----------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndAddedCollection(cpCol);
            Assert.IsTrue(myBO.Status.IsDirty);
            _businessObjectCollectionTestHelper.AssertAddedAndRemovedEventsNotFired();

            //---------------Execute Test ----------------------
            myBO.CancelEdits();

            //---------------Test Result -----------------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndAddedCollection(cpCol);
            Assert.IsFalse(myBO.Status.IsDirty);
            _businessObjectCollectionTestHelper.AssertAddedAndRemovedEventsNotFired();
        }
コード例 #58
0
        public void Test_Add_PersistedBO_CancelEdits()
        {
            //---------------Set up test pack-------------------
            //The persisted objects are added to the added cpCollection
            // when restore is called the added objects should be removed from the cpCollection.
            BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
            ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson();
            ContactPersonTestBO myBO2 = ContactPersonTestBO.CreateSavedContactPerson();
            ContactPersonTestBO myBO3 = ContactPersonTestBO.CreateSavedContactPerson();
            cpCol.Add(myBO, myBO2, myBO3);
            _businessObjectCollectionTestHelper.RegisterForRemovedEvent(cpCol);

            //-------Assert Preconditions
            Assert.AreEqual(3, cpCol.Count, "Three objects should be in the copied cpCollection");
            Assert.AreEqual(3, cpCol.AddedBusinessObjects.Count, "Three objects should be in the cpCollection");
            _businessObjectCollectionTestHelper.AssertRemovedEventNotFired();
            ///---------------Execute Test ----------------------
            cpCol.CancelEdits();

            //---------------Test Result ----------------------- - Result
            BusinessObjectCollectionTestHelper.AssertAllCollectionsHaveNoItems(cpCol);
            _businessObjectCollectionTestHelper.AssertRemovedEventFired();
        }
コード例 #59
0
        public void TestInitGrid_GlobalDateFormat_FormatsDateColumn()
        {
            //---------------Set up test pack-------------------
            IClassDef classDef = MyBO.LoadClassDefWithDateTimeParameterFormat();
            IReadOnlyGridControl grid = CreateReadOnlyGridControl();
            IGridInitialiser initialiser = new GridInitialiser(grid, GetControlFactory());
            IUIDef uiDef = classDef.UIDefCol["default"];
            IUIGrid uiGridDef = uiDef.UIGrid;
            AddControlToForm(grid);
            const string dateTimeNoFormatPropertyName = "TestDateTimeNoFormat";

            const string expectedFormat = "dd.MMM.yyyy";
            GlobalUIRegistry.DateDisplaySettings = new DateDisplaySettings();
            GlobalUIRegistry.DateDisplaySettings.GridDateFormat = expectedFormat;
            //--------------Assert PreConditions----------------            
            IUIGridColumn dateTimeNoFormatGridColumn = uiGridDef[dateTimeNoFormatPropertyName];
            Assert.IsNotNull(dateTimeNoFormatGridColumn);
            Assert.IsNull(dateTimeNoFormatGridColumn.GetParameterValue("dateFormat"));
            Assert.IsNotNull(GlobalUIRegistry.DateDisplaySettings);
            Assert.AreEqual(expectedFormat, GlobalUIRegistry.DateDisplaySettings.GridDateFormat);

            MyBO myBo = new MyBO();
            DateTime currentDateTime = DateTime.Now;
            myBo.SetPropertyValue(dateTimeNoFormatPropertyName, currentDateTime);
            BusinessObjectCollection<MyBO> col = new BusinessObjectCollection<MyBO>();
            col.Add(myBo);

            //---------------Execute Test ----------------------
            initialiser.InitialiseGrid(classDef);
            grid.BusinessObjectCollection = col;

            //---------------Test Result -----------------------
            Assert.AreEqual(1, col.Count);
            Assert.AreEqual(1, grid.Grid.Rows.Count);
            IDataGridViewCell dataGridViewCell = grid.Grid.Rows[0].Cells[dateTimeNoFormatPropertyName];
            //((DataGridViewCellVWG) dataGridViewCell).DataGridViewCell.HasStyle = false;
            Assert.AreSame(typeof(DateTime), dataGridViewCell.ValueType);
            Assert.AreEqual(currentDateTime.ToString(expectedFormat), dataGridViewCell.FormattedValue);

            //---------------Tear Down -------------------------          
        }
コード例 #60
0
        public void TestAddMethod_Refresh_LoadWithCriteria_BusinessObject()
        {
            //---------------Set up test pack-------------------
            BusinessObjectCollection<ContactPersonTestBO> cpCol = new BusinessObjectCollection<ContactPersonTestBO>();
            cpCol.Load("Surname='bbb'", "");
            ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson("aaa");

            cpCol.Add(myBO);
            _businessObjectCollectionTestHelper.RegisterForAddedAndRemovedEvents(cpCol);

            //---------------Assert Precondition----------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndAddedCollection(cpCol);
            Assert.IsFalse(myBO.Status.IsDirty);
            _businessObjectCollectionTestHelper.AssertAddedAndRemovedEventsNotFired();
            //---------------Execute Test ----------------------
            cpCol.Refresh();

            //---------------Test Result -----------------------
            BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndAddedCollection(cpCol);
            Assert.IsFalse(myBO.Status.IsDirty);
            _businessObjectCollectionTestHelper.AssertAddedAndRemovedEventsNotFired();
        }