Example #1
0
        public override bool Equals(object obj)
        {
            LunComboBoxItem cf = obj as LunComboBoxItem;

            if (cf == null)
            {
                return(false);
            }

            return(Vdi.Equals(cf.Vdi));
        }
Example #2
0
 public void ItemMatchingWithMatchingValues()
 {
     Mock<VDI> vdi = GetMockVdi(0);
     LunComboBoxItem item = new LunComboBoxItem(vdi.Object){AdditionalConstraints = new List<Predicate<VDI>>()};
     LunComboBoxItem secondItem = new LunComboBoxItem(vdi.Object) { AdditionalConstraints = new List<Predicate<VDI>>() };
     item.EnableItemMatching(secondItem);
     Assert.That(item.Enabled, Is.True);
     item.DisableItemMatching(secondItem);
     Assert.That(item.Enabled, Is.False);
     item.EnableItemMatching(secondItem);
     Assert.That(item.Enabled, Is.True);
 }
Example #3
0
        private void SetMatchingItemEnabledState(LunComboBoxItem itemToMatch, bool enabledState)
        {
            if (itemToMatch == null)
            {
                return;
            }

            if (Vdi == itemToMatch.Vdi)
            {
                enabled = enabledState;
            }
        }
Example #4
0
        /// <summary>
        /// Deal with the changes made to the dropdown cell by firing an event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dataGridViewCell_CurrentCellDirtyStateChanged(object sender, EventArgs e)
        {
            dataGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);

            foreach (LunPerVdiPickerItem row in dataGridView.SelectedRows)
            {
                LunComboBoxItem item = row.Cells[LunColumn.Index].Value as LunComboBoxItem;
                DisableOtherEquivalentValues(item, row.Index);
            }

            if (OnSelectionChanged != null)
            {
                OnSelectionChanged(this, new EventArgs());
            }
        }
Example #5
0
        private void EnableAllEquivalentValues(LunComboBoxItem item)
        {
            foreach (LunPerVdiPickerItem row in dataGridView.Rows)
            {
                DataGridViewEnableableComboBoxCell cb = row.Cells[LunColumn.Index] as DataGridViewEnableableComboBoxCell;
                if (cb == null)
                {
                    return;
                }

                foreach (LunComboBoxItem i in cb.Items)
                {
                    i.EnableItemMatching(item);
                }
            }
            dataGridView.Refresh();
        }
Example #6
0
        private void DisableOtherEquivalentValues(LunComboBoxItem item, int excludingRowIndex)
        {
            foreach (LunPerVdiPickerItem row in dataGridView.Rows)
            {
                DataGridViewEnableableComboBoxCell cb = row.Cells[LunColumn.Index] as DataGridViewEnableableComboBoxCell;
                if (cb == null)
                {
                    return;
                }

                if (row.Index != excludingRowIndex)
                {
                    foreach (LunComboBoxItem i in cb.Items)
                    {
                        i.DisableItemMatching(item);
                    }
                }
            }
            dataGridView.Refresh();
        }
Example #7
0
 public void DisableItemMatching(LunComboBoxItem itemToDisable)
 {
     SetMatchingItemEnabledState(itemToDisable, false);
 }
Example #8
0
        private void EnableAllEquivalentValues(LunComboBoxItem item)
        {
            foreach (LunPerVdiPickerItem row in dataGridView.Rows)
            {
                DataGridViewEnableableComboBoxCell cb = row.Cells[LunColumn.Index] as DataGridViewEnableableComboBoxCell;
                if (cb == null)
                    return;

                foreach (LunComboBoxItem i in cb.Items)
                {
                    i.EnableItemMatching(item);
                }
            }
            dataGridView.Refresh();
        } 
Example #9
0
        private void DisableOtherEquivalentValues(LunComboBoxItem item, int excludingRowIndex)
        {
            foreach (LunPerVdiPickerItem row in dataGridView.Rows)
            {
                DataGridViewEnableableComboBoxCell cb = row.Cells[LunColumn.Index] as DataGridViewEnableableComboBoxCell;
                if (cb == null)
                    return;

                if (row.Index != excludingRowIndex)
                {
                    foreach (LunComboBoxItem i in cb.Items)
                    {
                        i.DisableItemMatching(item);
                    }
                }
            }
            dataGridView.Refresh();
        }
Example #10
0
 public void EnableItemMatching(LunComboBoxItem itemToEnable)
 {
     SetMatchingItemEnabledState(itemToEnable, true);
 }
Example #11
0
 public bool VBDCountDisablesItem(int vbdCount)
 {
     Mock<VDI> vdi = GetMockVdi(vbdCount);
     LunComboBoxItem item = new LunComboBoxItem(vdi.Object);
     return item.Enabled;
 }
Example #12
0
 public void NullAdditionalConstraintsThrows()
 {
     Mock<VDI> vdi = GetMockVdi(0);
     LunComboBoxItem item = new LunComboBoxItem(vdi.Object) { AdditionalConstraints = null };
     bool b = item.Enabled;
 }
Example #13
0
 public void AdditionalConstraintsDisableItem(List<Predicate<VDI>> constraints, bool expectedEnabled, string description )
 {
     Mock<VDI> vdi = GetMockVdi(0);
     LunComboBoxItem item = new LunComboBoxItem(vdi.Object) {AdditionalConstraints = constraints};
     Assert.That(item.Enabled, Is.EqualTo(expectedEnabled), description);
 }
Example #14
0
 public void EnableItemMatching(LunComboBoxItem itemToEnable)
 {
     SetMatchingItemEnabledState(itemToEnable, true);
 }
Example #15
0
 public void DisableItemMatching(LunComboBoxItem itemToDisable)
 {
     SetMatchingItemEnabledState(itemToDisable, false);
 }
Example #16
0
        private void SetMatchingItemEnabledState(LunComboBoxItem itemToMatch, bool enabledState)
        {
            if (itemToMatch == null)
                return;

            if (Vdi == itemToMatch.Vdi)
                enabled = enabledState;
        }
Example #17
0
 public void ItemToStringIncludeSizeDetails(string sizeText, string nameLabel, string expectedResult)
 {
     Mock<VDI> vdi = GetMockVdi(0);
     vdi.Setup(v => v.SizeText).Returns(sizeText);
     vdi.Setup(v => v.name_label).Returns(nameLabel);
     LunComboBoxItem item = new LunComboBoxItem(vdi.Object);
     Assert.That(item.ToString(), Is.EqualTo(expectedResult));
 }