当前位置: 首页>>代码示例>>C#>>正文


C# BusinessObjectCollection.Add方法代码示例

本文整理汇总了C#中BusinessObjectCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# BusinessObjectCollection.Add方法的具体用法?C# BusinessObjectCollection.Add怎么用?C# BusinessObjectCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BusinessObjectCollection的用法示例。


在下文中一共展示了BusinessObjectCollection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestBusinessObjectControlHasDifferentBOWhenTabChanges

        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);
        }
开发者ID:Chillisoft,项目名称:habanero.faces,代码行数:26,代码来源:TestBOColTabControlVWG.cs

示例2: InitialiseCollection

 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());
 }
开发者ID:kevinbosman,项目名称:habanero,代码行数:8,代码来源:TestReflectedPropertyComparer.cs

示例3: TestAddRowCreatesBusinessObjectThroughCollection

        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");
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:37,代码来源:TestEditableDataSetProvider.cs

示例4: Test_AddMethod

 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");
 }
开发者ID:kevinbosman,项目名称:habanero,代码行数:19,代码来源:TestBusinessObjectCollection_AddedBOs.cs

示例5: TestCreateTestListBoxCollectionController

        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 -------------------------   
        }
开发者ID:Chillisoft,项目名称:habanero.faces,代码行数:20,代码来源:TestListBoxCollectionManager.cs

示例6: Test_MarkForDelete_Added_AddBo

        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();
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:22,代码来源:TestBusinessObjectCollection_AddedBOs.cs

示例7: TestAddMethod_PersistedObject_IgnoresAddWhenItemAlreadyExists

        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();
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:18,代码来源:TestBusinessObjectCollection_AddedBOs.cs

示例8: TestInitGrid_UIDef_CurrencyFormat_WhenVirtualProp_ShouldFormatColumn

        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);
        }
开发者ID:Chillisoft,项目名称:habanero.faces,代码行数:42,代码来源:TestGridInitialiser.cs

示例9: Test_EditDataTable_WhenVirtualProp_ShouldEditRelatedVirtualProp

        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();
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:33,代码来源:TestEditableDataSetProvider.cs

示例10: GetControlFactory

            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);
        }
开发者ID:Chillisoft,项目名称:habanero.faces,代码行数:32,代码来源:TestCollectionComboBoxMapper.cs

示例11: TestSerialiseDeserialiseBusinessObjectCollection_EventsAreSetUp

        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);
   
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:28,代码来源:TestBusinessObjectSerialisation.cs

示例12: TestSetCollection

        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 -------------------------
        }
开发者ID:Chillisoft,项目名称:habanero.faces,代码行数:20,代码来源:TestCollectionTabControlMapper.cs

示例13: Test_AddMethod_WithParamArray

 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");
 }
开发者ID:kevinbosman,项目名称:habanero,代码行数:16,代码来源:TestBusinessObjectCollection_AddedBOs.cs

示例14: Test_MarkForDelete_Added_boSave

        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);
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:20,代码来源:TestBusinessObjectCollection_AddedBOs.cs

示例15: TestAddMethod_IgnoresAddWhenItemAlreadyExists

        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();
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:19,代码来源:TestBusinessObjectCollection_AddedBOs.cs


注:本文中的BusinessObjectCollection.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。