/// <summary> Sets the new value of the <see cref="DataSource"/> property. </summary> /// <param name="dataSource"> The new <see cref="IBusinessObjectDataSource"/>. Can be <see langword="null"/>. </param> private void SetDataSource(IBusinessObjectDataSource dataSource) { if (_control == dataSource && _control is IBusinessObjectReferenceDataSource) { throw new ArgumentException("Assigning a reference data source as its own data source is not allowed.", "value"); } if (_dataSource == dataSource) { return; } if (_dataSource != null) { _dataSource.Unregister(_control); } _dataSource = dataSource; if (dataSource != null) { dataSource.Register(_control); } _bindingChanged = true; }
/// <summary> /// Adds the passed <see cref="IBusinessObjectBoundControl"/> to the list of controls bound to this <see cref="BusinessObjectDataSourceControl"/>. /// </summary> /// <param name="control"> /// The <see cref="IBusinessObjectBoundControl"/> to be registered with this <see cref="BusinessObjectDataSourceControl"/>. /// </param> /// <remarks> /// Executes the <see cref="IBusinessObjectDataSource.Register"/> method of the encapsulated <see cref="IBusinessObjectDataSource"/>. /// </remarks> public virtual void Register(IBusinessObjectBoundControl control) { InnerDataSource.Register(control); }
public void RegisterAndGetBoundControls() { var stubControl1 = _mockRepository.Stub <IBusinessObjectBoundControl>(); var stubControl2 = _mockRepository.Stub <IBusinessObjectBoundControl>(); _mockRepository.ReplayAll(); _dataSource.Register(stubControl1); _dataSource.Register(stubControl2); Assert.That(_dataSource.GetAllBoundControls(), Is.EqualTo(new[] { stubControl1, stubControl2 })); _mockRepository.VerifyAll(); }