public override void SetUp()
        {
            base.SetUp();

            _editModeHost                           = new FakeEditModeHost();
            _editModeHost.ID                        = "BocList";
            _editModeHost.RowIDProvider             = new FakeRowIDProvider();
            _editModeHost.EditModeControlFactory    = EditableRowControlFactory.CreateEditableRowControlFactory();
            _editModeHost.EditModeDataSourceFactory = new EditableRowDataSourceFactory();

            _editableRow    = new EditableRow(_editModeHost);
            _editableRow.ID = "Row";
            NamingContainer.Controls.Add(_editableRow);

            _value01 = (IBusinessObject)TypeWithAllDataTypes.Create("A", 1);

            _typeWithAllDataTypesClass = BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(TypeWithAllDataTypes));

            _typeWithAllDataTypesStringValuePath = BusinessObjectPropertyPath.CreateStatic(_typeWithAllDataTypesClass, "String");
            _typeWithAllDataTypesInt32ValuePath  = BusinessObjectPropertyPath.CreateStatic(_typeWithAllDataTypesClass, "Int32");

            _typeWithAllDataTypesStringValueSimpleColumn = new BocSimpleColumnDefinition();
            _typeWithAllDataTypesStringValueSimpleColumn.SetPropertyPath(_typeWithAllDataTypesStringValuePath);

            _typeWithAllDataTypesStringValueSimpleColumnAsDynamic = new BocSimpleColumnDefinition();
            _typeWithAllDataTypesStringValueSimpleColumnAsDynamic.SetPropertyPath(BusinessObjectPropertyPath.CreateDynamic("StringValue"));
            _typeWithAllDataTypesStringValueSimpleColumnAsDynamic.IsDynamic = true;

            _typeWithAllDataTypesInt32ValueSimpleColumn = new BocSimpleColumnDefinition();
            _typeWithAllDataTypesInt32ValueSimpleColumn.SetPropertyPath(_typeWithAllDataTypesInt32ValuePath);

            _typeWithAllDataTypesStringValueFirstValueCompoundColumn = new BocCompoundColumnDefinition();
            _typeWithAllDataTypesStringValueFirstValueCompoundColumn.PropertyPathBindings.Add(
                new PropertyPathBinding(_typeWithAllDataTypesStringValuePath));
            _typeWithAllDataTypesStringValueFirstValueCompoundColumn.PropertyPathBindings.Add(
                new PropertyPathBinding(_typeWithAllDataTypesStringValuePath));
            _typeWithAllDataTypesStringValueFirstValueCompoundColumn.FormatString = "{0}, {1}";

            _typeWithAllDataTypesStringValueCustomColumn = new BocCustomColumnDefinition();
            _typeWithAllDataTypesStringValueCustomColumn.SetPropertyPath(_typeWithAllDataTypesStringValuePath);
            _typeWithAllDataTypesStringValueCustomColumn.IsSortable = true;

            _commandColumn      = new BocCommandColumnDefinition();
            _rowEditModeColumn  = new BocRowEditModeColumnDefinition();
            _dropDownMenuColumn = new BocDropDownMenuColumnDefinition();
        }
        public override void SetUp()
        {
            base.SetUp();

            _actualEvents = new StringCollection();

            _values    = new IBusinessObject[5];
            _values[0] = (IBusinessObject)TypeWithAllDataTypes.Create("A", 1);
            _values[1] = (IBusinessObject)TypeWithAllDataTypes.Create("B", 2);
            _values[2] = (IBusinessObject)TypeWithAllDataTypes.Create("C", 3);
            _values[3] = (IBusinessObject)TypeWithAllDataTypes.Create("D", 4);
            _values[4] = (IBusinessObject)TypeWithAllDataTypes.Create("E", 5);

            _newValues    = new IBusinessObject[2];
            _newValues[0] = (IBusinessObject)TypeWithAllDataTypes.Create("F", 6);
            _newValues[1] = (IBusinessObject)TypeWithAllDataTypes.Create("G", 7);

            _class = BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(TypeWithAllDataTypes));

            _stringValuePath = BusinessObjectPropertyPath.CreateStatic(_class, "String");
            _int32ValuePath  = BusinessObjectPropertyPath.CreateStatic(_class, "Int32");

            _stringValueSimpleColumn = new BocSimpleColumnDefinition();
            _stringValueSimpleColumn.SetPropertyPath(_stringValuePath);

            _int32ValueSimpleColumn = new BocSimpleColumnDefinition();
            _int32ValueSimpleColumn.SetPropertyPath(_int32ValuePath);

            _columns    = new BocColumnDefinition[2];
            _columns[0] = _stringValueSimpleColumn;
            _columns[1] = _int32ValueSimpleColumn;

            _editModeHost    = new FakeEditModeHost();
            _editModeHost.ID = "BocList";

            _controller    = new EditModeController(_editModeHost);
            _controller.ID = "Controller";
            NamingContainer.Controls.Add(_controller);

            _controllerInvoker = new ControlInvoker(_controller);

            _editModeHost.NotifyOnEditableRowChangesCanceled  = (i, o) => _actualEvents.Add(FormatChangesCanceledEventMessage(i, o));
            _editModeHost.NotifyOnEditableRowChangesCanceling = (i, o) => _actualEvents.Add(FormatChangesCancelingEventMessage(i, o));
            _editModeHost.NotifyOnEditableRowChangesSaved     = (i, o) => _actualEvents.Add(FormatChangesSavedEventMessage(i, o));
            _editModeHost.NotifyOnEditableRowChangesSaving    = (i, o) => _actualEvents.Add(FormatChangesSavingEventMessage(i, o));
            _editModeHost.NotifyAddRows =
                objects =>
            {
                var oldLength = _editModeHost.Value.Count;
                _editModeHost.Value = ((IBusinessObject[])_editModeHost.Value).Concat(objects).ToArray();
                return(((IBusinessObject[])_editModeHost.Value).Select((o, i) => new BocListRow(i, o)).Skip(oldLength).ToArray());
            };
            _editModeHost.NotifyRemoveRows =
                objects =>
            {
                var removedRows = ((IBusinessObject[])_editModeHost.Value)
                                  .Select((o, i) => new BocListRow(i, o))
                                  .Where(r => objects.Contains(r.BusinessObject))
                                  .ToArray();
                _editModeHost.Value = ((IBusinessObject[])_editModeHost.Value).Except(objects).ToArray();
                return(removedRows);
            };
            _editModeHost.NotifyEndRowEditModeCleanUp  = i => _actualEvents.Add(FormatEndRowEditModeCleanUp(i));
            _editModeHost.NotifyEndListEditModeCleanUp = () => _actualEvents.Add(FormatEndListEditModeCleanUp());
            _editModeHost.NotifyValidateEditableRows   = () => _actualEvents.Add(FormatValidateEditableRows());
            _editModeHost.Value                     = _values;
            _editModeHost.RowIDProvider             = new FakeRowIDProvider();
            _editModeHost.EditModeControlFactory    = EditableRowControlFactory.CreateEditableRowControlFactory();
            _editModeHost.EditModeDataSourceFactory = new EditableRowDataSourceFactory();
            _editModeHost.EnableEditModeValidator   = true;
            _editModeHost.AreCustomCellsValid       = true;
        }