public void TestSetCurrentSelectedProductAndNotifyObserver()
        {
            var product = new Product(TestDefinition.DUMP_INTEGER, TestDefinition.DUMP_STRING, TestDefinition.DUMP_STRING, new Money(TestDefinition.DUMP_INTEGER), TestDefinition.DUMP_INTEGER, TestDefinition.DUMP_STRING, TestDefinition.DUMP_STRING);
            int count   = 0;

            _productsManagementTabPagePresentationModel.CurrentSelectedProductChanged += () => count++;
            _productsManagementTabPagePresentationModel.SetCurrentSelectedProductAndNotifyObserver(product);
            Assert.AreSame(_target.GetFieldOrProperty(MEMBER_VARIABLE_NAME_CURRENT_SELECTED_PRODUCT), product);
            Assert.AreEqual(count, 1);
        }
 public ProductManagementForm(ProductsManagementTabPagePresentationModel productsManagementTabPagePresentationModelData, ProductTypesManagementTabPagePresentationModel productTypesManagementTabPagePresentationModelData, Model modelData)
 {
     InitializeComponent();
     _productsManagementTabPagePresentationModel     = productsManagementTabPagePresentationModelData;
     _productTypesManagementTabPagePresentationModel = productTypesManagementTabPagePresentationModelData;
     _model         = modelData;
     this.Disposed += RemoveEvents;
     // Observers
     _model.ProductInfoChanged += ResetViewOnProductInfoChangedOrOnProductAdded;
     _model.ProductAdded       += ResetViewOnProductInfoChangedOrOnProductAdded;
     _model.ProductTypeAdded   += ResetViewOnProductTypeAdded;
     _productsManagementTabPagePresentationModel.CurrentSelectedProductChanged                 += UpdateProductInfoViewAndSetIsEditedProductInfo;
     _productsManagementTabPagePresentationModel.SubmitProductInfoButtonEnabledChanged         += UpdateSubmitProductInfoButtonView;
     _productTypesManagementTabPagePresentationModel.CurrentSelectedProductTypeChanged         += UpdateProductTypeInfoView;
     _productTypesManagementTabPagePresentationModel.SubmitProductTypeInfoButtonEnabledChanged += UpdateProductTypeInfoButtonView;
     // UI
     _productsListBox.SelectedIndexChanged     += ChangeProductsListBoxSelectedIndex;
     _productTypesListBox.SelectedIndexChanged += ChangeProductTypesListBoxSelectedIndex;
     _productPriceField.KeyPress        += InputHelper.InputNumbersOrBackSpace;
     _productImageBrowseButton.Click    += (sender, eventArguments) => BrowseImageAndSetProductImagePath();
     _submitProductInfoButton.Click     += (sender, eventArguments) => _productsManagementTabPagePresentationModel.ClickSubmitProductInfoButton(new ProductInfo(_productNameField.Text, _productTypeField.Text, new Money(int.Parse(_productPriceField.Text)), _productDescriptionField.Text, _productImagePathField.Text));
     _submitProductTypeInfoButton.Click += (sender, eventArguments) => _productTypesManagementTabPagePresentationModel.ClickSubmitProductTypeInfoButton(_productTypeNameField.Text);
     _addProductButton.Click            += (sender, eventArguments) => SetProductsManagementTabPageStateAndUpdateViewOnAddProductButtonClicked();
     _addProductTypeButton.Click        += (sender, eventArguments) => SetProductTypesManagementTabPageStateAndUpdateViewOnAddProductTypeButtonClicked();
     // Product info
     _productNameField.TextChanged        += (sender, eventArguments) => _productsManagementTabPagePresentationModel.SetIsEditedProductInfoAndNotifyObserver(true);
     _productPriceField.TextChanged       += (sender, eventArguments) => _productsManagementTabPagePresentationModel.SetIsEditedProductInfoAndNotifyObserver(true);
     _productTypeField.TextChanged        += (sender, eventArguments) => _productsManagementTabPagePresentationModel.SetIsEditedProductInfoAndNotifyObserver(true);
     _productImagePathField.TextChanged   += (sender, eventArguments) => _productsManagementTabPagePresentationModel.SetIsEditedProductInfoAndNotifyObserver(true);
     _productDescriptionField.TextChanged += (sender, eventArguments) => _productsManagementTabPagePresentationModel.SetIsEditedProductInfoAndNotifyObserver(true);
     // Input inspecting textboxes
     InitializeInputInspectingTextBoxesTextBoxInspectors();
     InitializeInputInspectingTextBoxes();
     InitializeInputInspectingTextBoxesTextBoxInspectorsCollectionChangedEventHandlers();
     // Input inspecting drop-down lists
     InitializeInputInspectingDropDownListsDropDownListInspectors();
     InitializeInputInspectingDropDownLists();
     InitializeInputInspectingDropDownListsDropDownListInspectorsCollectionChangedEventHandlers();
     // Input inspectors collection
     InitializeInputInspectorsCollection();
     // Input inspecting textbox of product types management tab page
     _productTypeNameField.AddTextBoxInspectors(InputInspectorTypeHelper.FLAG_TEXT_BOX_IS_NOT_EMPTY);
     _productTypeNameField.TextBoxInspectorsCollectionChanged += () => UpdateErrorProviderViewAndIsValidProductTypeInfo(_productTypeNameField, _productTypeNameField.GetInputInspectorsError());
     // Initial UI States
     InitializeProductTypeField();
     InitializeProductsListBox();
     InitializeProductTypesListBox();
     _productsManagementTabPagePresentationModel.SetCurrentSelectedProductAndNotifyObserver(null);
     _productsManagementTabPagePresentationModel.SetIsValidProductInfoAndNotifyObserver(false);
     _productsManagementTabPagePresentationModel.SetIsEditedProductInfoAndNotifyObserver(false);
     _productsManagementTabPagePresentationModel.SetProductsManagementTabPageStateAndNotifyObserver(ProductsManagementTabPageState.EditProduct);
     _productTypesManagementTabPagePresentationModel.SetCurrentSelectedProductTypeAndNotifyObserver(null);
     _productTypesManagementTabPagePresentationModel.SetIsValidProductTypeInfoAndNotifyObserver(false);
     _productTypesManagementTabPagePresentationModel.SetProductTypesManagementTabPageStateAndNotifyObserver(ProductTypesManagementTabPageState.ViewProductType);
 }
 /// <summary>
 /// Change _productsListBox.SelectedIndex.
 /// </summary>
 private void ChangeProductsListBoxSelectedIndex(object sender, EventArgs eventArguments)
 {
     _productsManagementTabPagePresentationModel.SetProductsManagementTabPageStateAndNotifyObserver(ProductsManagementTabPageState.EditProduct);
     _productsManagementTabPagePresentationModel.SetCurrentSelectedProductAndNotifyObserver((( ProductsListBoxItem )_productsListBox.SelectedItem).Product);
     UpdateViewOnProductsListBoxSelectedIndexChanged();
 }