public void TestProductsManagementTabPagePresentationModel()
        {
            Assert.ThrowsException <ArgumentNullException>(() => new ProductsManagementTabPagePresentationModel(null));
            var productsManagementTabPagePresentationModel = new ProductsManagementTabPagePresentationModel(new Model(TestDefinition.DUMP_STRING));
            var target = new PrivateObject(productsManagementTabPagePresentationModel);

            Assert.IsNotNull(target.GetFieldOrProperty(MEMBER_VARIABLE_NAME_MODEL));
        }
 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);
 }
 public MainForm(CreditCardPaymentForm creditCardPaymentFormData, OrderPresentationModel orderPresentationModelData, ProductsManagementTabPagePresentationModel productsManagementTabPagePresentationModelData, ProductTypesManagementTabPagePresentationModel productTypesManagementTabPagePresentationModelData, Model modelData)
 {
     InitializeComponent();
     _creditCardPaymentForm  = creditCardPaymentFormData;
     _orderPresentationModel = orderPresentationModelData;
     _productsManagementTabPagePresentationModel     = productsManagementTabPagePresentationModelData;
     _productTypesManagementTabPagePresentationModel = productTypesManagementTabPagePresentationModelData;
     _model = modelData;
     _orderSystemButton.Click         += ClickOrderSystemButton;
     _inventorySystemButton.Click     += ClickInventorySystemButton;
     _productManageSystemButton.Click += ClickProductManageSystemButton;
     _exitButton.Click += ClickExitButton;
 }
 public void Initialize()
 {
     _productsManagementTabPagePresentationModel = new ProductsManagementTabPagePresentationModel(new Model(Resources.ProductsTableTest));
     _target = new PrivateObject(_productsManagementTabPagePresentationModel);
 }