当前位置: 首页>>代码示例>>C#>>正文


C# Variables.ExpandValues方法代码示例

本文整理汇总了C#中Variables.ExpandValues方法的典型用法代码示例。如果您正苦于以下问题:C# Variables.ExpandValues方法的具体用法?C# Variables.ExpandValues怎么用?C# Variables.ExpandValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Variables的用法示例。


在下文中一共展示了Variables.ExpandValues方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExpandValues_HandlesNullValue

        public void ExpandValues_HandlesNullValue()
        {
            using (TestHostContext hc = new TestHostContext(this))
            {
                // Arrange: Setup the variables.
                List<string> warnings;
                var variableDictionary = new Dictionary<string, string>
                {
                    { "variable1", "some variable 1 value " },
                };
                var variables = new Variables(hc, variableDictionary, new List<MaskHint>(), out warnings);

                // Arrange: Setup the target dictionary.
                var targetDictionary = new Dictionary<string, string>
                {
                    { "some target key", null },
                };

                // Act.
                variables.ExpandValues(target: targetDictionary);

                // Assert: The consecutive macros should both have been expanded.
                Assert.Equal(string.Empty, targetDictionary["some target key"]);
            }
        }
开发者ID:codedebug,项目名称:vsts-agent,代码行数:25,代码来源:VariablesL0.cs

示例2: ExpandValues_HandlesPreceedingPrefix

        public void ExpandValues_HandlesPreceedingPrefix()
        {
            using (TestHostContext hc = new TestHostContext(this))
            {
                // Arrange: Setup the variables.
                List<string> warnings;
                var variableDictionary = new Dictionary<string, string>
                {
                    { "variable1", "some variable 1 value" },
                };
                var variables = new Variables(hc, variableDictionary, new List<MaskHint>(), out warnings);

                // Arrange: Setup the target dictionary.
                var targetDictionary = new Dictionary<string, string>();
                targetDictionary["some target key"] = "before $($(variable1) after";

                // Act.
                variables.ExpandValues(target: targetDictionary);

                // Assert: The consecutive macros should both have been expanded.
                Assert.Equal("before $(some variable 1 value after", targetDictionary["some target key"]);
            }
        }
开发者ID:codedebug,项目名称:vsts-agent,代码行数:23,代码来源:VariablesL0.cs

示例3: ExpandValues_DoesNotRecurse

        public void ExpandValues_DoesNotRecurse()
        {
            using (TestHostContext hc = new TestHostContext(this))
            {
                // Arrange: Setup the variables. The value of the variable1 variable
                // should not get expanded since variable2 does not exist when the
                // variables class is initialized (and therefore would never get expanded).
                List<string> warnings;
                var variableDictionary = new Dictionary<string, string>
                {
                    { "variable1", "$(variable2)" },
                };
                var variables = new Variables(hc, variableDictionary, new List<MaskHint>(), out warnings);
                variables.Set("variable2", "some variable 2 value");

                // Arrange: Setup the target dictionary.
                var targetDictionary = new Dictionary<string, string>();
                targetDictionary["some target key"] = "before $(variable1) after";

                // Act.
                variables.ExpandValues(target: targetDictionary);

                // Assert: The variable should only have been expanded one level.
                Assert.Equal("before $(variable2) after", targetDictionary["some target key"]);
            }
        }
开发者ID:codedebug,项目名称:vsts-agent,代码行数:26,代码来源:VariablesL0.cs


注:本文中的Variables.ExpandValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。