public void ConvertToDotnetType_ReturnsExpectedDotnetType(ArmValueTypes armType,
                                                                  Type dotnetType)
        {
            var actual = ArmTypesConverter.ConvertToDotnetType(armType);

            Assert.Equal(dotnetType.ToString(), actual.ToString());
        }
Esempio n. 2
0
        public void AddExpression_SetsExpectedTemplateOutputTypeAndValue(string expressionText,
                                                                         ArmValueTypes expectedOutputType)
        {
            var expression = new ArmTemplateExpression(expressionText);
            var actual     = new TemplateBuilder()
                             .AddExpression(expression, expectedOutputType)
                             .Template["outputs"]["expression"];

            Assert.IsType <JObject>(actual);
            Assert.Equal(expectedOutputType.ToString(), actual["Type"].ToString());
            Assert.Equal(expressionText, actual["Value"].ToString());
        }
Esempio n. 3
0
        public void Invoke_NoVariableOrParameter_ReturnsExpectedOutput(
            string text,
            ArmValueTypes expectedOutputType,
            string outputValue,
            string expectedoutputString
            )
        {
            var expression = new ArmTemplateExpression(text);
            var deployment = new MockArmDeployment()
                             .MockInvoke(expectedOutputType.ToString(), outputValue)
                             .Object;

            var actual = expression.Invoke(deployment, expectedOutputType, null, null);

            Assert.Equal(expectedoutputString, actual.ToString());
        }
Esempio n. 4
0
        public TemplateBuilder AddExpression(ArmTemplateExpression expression, ArmValueTypes expectedOutputType)
        {
            if (expression is null)
            {
                throw new ArgumentNullException(nameof(expression));
            }

            JObject OutputObj = new JObject(
                new JProperty(
                    "expression", new JObject(
                        new JProperty("Type", expectedOutputType.ToString()),
                        new JProperty("Value", expression.Text)
                    )
                )
            );
            Template["outputs"] = OutputObj;
            return this;
        }
Esempio n. 5
0
        public void Invoke_WithParameters_ReturnsExpectedOutput(
            string text,
            ICollection <ArmTemplateParameter> inputParameters,
            ICollection <ArmTemplateVariable> inputVariables,
            ArmValueTypes expectedOutputType,
            string outputValue,
            string expectedOutputString
            )
        {
            var expression = new ArmTemplateExpression(text);
            var deployment = new MockArmDeployment()
                             .MockInvoke(expectedOutputType.ToString(), outputValue)
                             .Object;

            var actual = expression.Invoke(deployment, expectedOutputType, inputParameters, inputVariables);

            Assert.Equal(expectedOutputString, actual.ToString());
        }
Esempio n. 6
0
        public static Type ConvertToDotnetType(ArmValueTypes armType)
        {
            Type dotnetType;

            switch (armType)
            {
            case ArmValueTypes.array:
                dotnetType = typeof(Array);
                break;

            case ArmValueTypes.@bool:
                dotnetType = typeof(bool);
                break;

            case ArmValueTypes.@int:
                dotnetType = typeof(int);
                break;

            case ArmValueTypes.@object:
                dotnetType = typeof(object);
                break;

            case ArmValueTypes.secureObject:
                dotnetType = typeof(object);
                break;

            case ArmValueTypes.securestring:
                dotnetType = typeof(string);
                break;

            case ArmValueTypes.@string:
                dotnetType = typeof(string);
                break;

            default:
                throw new NotSupportedException();
            }
            return(dotnetType);
        }