コード例 #1
0
        public void HelperMethods_FindMatchingOutputFormats_ReturnsAtLeastOneOutputFormat()
        {
            // arrange & act
            var result      = OutputFormatHelper.GetCompatibleOutputFormats("Teststrasse 123", _testAssembly);
            var resultTypes = result
                              .Select(mapper => mapper.Type)
                              .ToList();

            // assert
            Assert.GreaterOrEqual(result.Count(), 3);
            Assert.Contains(typeof(InputSameAsOutputOutputFormat), resultTypes);
            Assert.Contains(typeof(InputSameAsOutputTwoGroupsOutputFormat), resultTypes);
            Assert.Contains(typeof(NoRegexGroupAttributeOutputFormat), resultTypes);
        }
コード例 #2
0
        /// <summary>
        /// Toggle all or matching output formats.
        /// </summary>
        /// <param name="sender">Sender of type <see cref="RibbonToggleButton"/>.</param>
        /// <param name="e">Event of ribbon control.</param>
        private void toggleFindMatch_Click(object sender, RibbonControlEventArgs e)
        {
            // sanity check
            var button    = sender as RibbonToggleButton;
            var selection = Globals.ThisAddIn.Application.ActiveCell as Range;

            if (button == null || selection == null)
            {
                return;
            }

            IEnumerable <DescriptionMapper> outputFormats = null;

            if (button.Checked == false)
            {
                // show all output formats
                outputFormats = OutputFormatHelper.GetMappings();
            }
            else
            {
                // show only matching output formats
                var firstSelectedCellValue = selection?.Value as string;
                if (string.IsNullOrWhiteSpace(firstSelectedCellValue))
                {
                    button.Checked = false;
                    MessageBox.Show(
                        Resources.Messages.PlaceCursorOntoAddress, Resources.Messages.IdentifyOutputFormats,
                        MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                outputFormats = OutputFormatHelper.GetCompatibleOutputFormats(firstSelectedCellValue);
            }

            // repopulate dropdown
            this.PopulateOutputFormats(outputFormats);
        }