Пример #1
0
        public void TemplateParameters()
        {
            var    templateTypes = AzureResourceGroupActionUtils.ExtractParameterTypes(template);
            string parameterJson = @"{
   ""object1"":{
      ""value"":{
         ""name"":""John""
      }
   },
   ""object2"":{
      ""value"":""#{MyObj}""
   },
   ""string"":{
      ""value"":""Hello John""
   },
   ""stringWithBadlyCaseType"":{
      ""value"":""Hello again John""
   },
   ""aSecureObject"":{
      ""value"":{""Value"":""Foo""}
   },
   ""int"":{
      ""value"":""#{MyInt}""
   },
   ""bool"":{
      ""value"":""#{MyBool}""
   },
   ""array"":{
      ""value"":""#{MyArray}""
   },
   ""int2"":{
      ""value"":55
   },
   ""bool2"":{
      ""value"":true
   },
   ""array2"":{
      ""value"":[""foo"", ""bar""]
   },
   ""complex"":{
      ""value"":""#{Complex} Smith""
   }
}";

            var variableDictionary = new TestVariableDictionary();

            variableDictionary.Set("MyObj", @"{ ""name"": ""Tim"" }");
            variableDictionary.Set("MyInt", "40");
            variableDictionary.Set("MyBool", Boolean.TrueString);
            variableDictionary.Set("MyArray", @"[ { ""points"": 67 }, { ""points"": 77 } ]");
            variableDictionary.Set("Complex", @"Hello #{if ATruthyVariable}Oliver#{else}Ella#{/if}");
            variableDictionary.Set("ATruthyVariable", Boolean.TrueString);
            var result = AzureResourceGroupActionUtils.TemplateParameters(parameterJson, templateTypes, variableDictionary);

            this.Assent(result, new Configuration().UsingNamer(new SashimiNamer()));
        }
Пример #2
0
        public void ExtractParameterTypes()
        {
            var result = AzureResourceGroupActionUtils.ExtractParameterTypes(template);

            result.Count.Should().Be(12);
            result.Should().ContainKeys("object1", "object2", "string", "stringWithBadlyCaseType", "aSecureObject", "int", "bool", "array", "int2", "bool2", "array2", "complex");
            result["object1"].Should().Be("object");
            result["object2"].Should().Be("object");
            result["string"].Should().Be("string");
            result["stringWithBadlyCaseType"].Should().Be("String");
            result["aSecureObject"].Should().Be("secureObject");
            result["int"].Should().Be("int");
            result["bool"].Should().Be("bool");
            result["array"].Should().Be("array");
        }