Exemple #1
0
        public void Format_正常系_パラメータと値の数が一致しているとき正常にフォーマット出来ること3()
        {
            var formatText = "{0}{1}{2}";
            var valuesText = "1\t2\t3";
            var result     = TextFormatMacro.Format(formatText, valuesText);

            Assert.AreEqual("123", result);
        } // end function
Exemple #2
0
        public void Format_準正常系_フォーマットにプレースホルダではない中括弧が含まれるときに無視してフォーマットされること4()
        {
            var formatText = "{0}{}";
            var valuesText = "1";
            var result     = TextFormatMacro.Format(formatText, valuesText);

            Assert.AreEqual("1{}", result);
        } // end function
        }     // end constructor

        #endregion

        #region MainControl(TextFormat)イベント処理

        /// <summary>
        /// メインコントロール の TextFormat で、ボタンが押されたときの処理を実行します。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainControl_Executed(object sender, EventArgs e)
        {
            var c       = sender as TextFormat;
            var macaron = new VisualStudioMacaron(this);

            try
            {
                macaron.ReplaceSelectionParagraphs(null, (a) =>
                {
                    // c(ツールウィンドウ)Text をフォーマット、a(エディタ)選択行を値として、フォーマット変換を実行します。
                    a.Text = TextFormatMacro.Format(c.Text, a.Text);
                });
            }
            catch (ActiveDocumentIsNullException)
            {
                macaron.ShowMessageBox(Resources.TextFormatCaption, Resources.MessageActivateTextEditorForFormatText);
            } // end try
        }     // end sub