Пример #1
0
 public IEnumerable <TestDef <ActionT> > MakeObjectTests()
 {
     for (var elementCount = 0; elementCount <= 2; elementCount++)
     {
         foreach (var contents in MakeValueListsOfLength(elementCount))
         {
             var names    = new List <string>();
             var encoding = new List <string>()
             {
                 "{"
             };
             var propActions = new List <PropertyAction <ActionT> >();
             for (var i = 0; i < contents.Count; i++)
             {
                 var td       = contents[i];
                 var propName = "prop" + i;
                 names.Add(propName + ": " + td.Name);
                 if (i > 0)
                 {
                     encoding.Add(",");
                 }
                 encoding.Add("\"" + propName + "\"");
                 encoding.Add(":");
                 encoding.AddRange(td.Encoding);
                 propActions.Add(new PropertyAction <ActionT>
                 {
                     Name    = propName,
                     Actions = td.Actions
                 });
             }
             encoding.Add("}");
             var value = new TestValue <ActionT>
             {
                 Type        = ValueType.Object,
                 ObjectValue = propActions.ToArray()
             };
             yield return(new TestDef <ActionT>
             {
                 Name = "object(" + string.Join(", ", names) + ")",
                 Encoding = encoding.ToArray(),
                 Actions = new ActionT[] { _valueTestFactory.Value(value, null) }
             });
         }
     }
 }
Пример #2
0
 public IEnumerable <TestDef <ActionT> > MakeArrayTests()
 {
     for (var elementCount = 0; elementCount <= 2; elementCount++)
     {
         foreach (var contents in MakeValueListsOfLength(elementCount))
         {
             var names    = new List <string>();
             var encoding = new List <string>()
             {
                 "["
             };
             var actions = new List <ActionT>();
             for (var i = 0; i < contents.Count; i++)
             {
                 var td = contents[i];
                 names.Add(td.Name);
                 if (i > 0)
                 {
                     encoding.Add(",");
                 }
                 encoding.AddRange(td.Encoding);
                 actions.AddRange(td.Actions);
             }
             encoding.Add("]");
             var value = new TestValue <ActionT>
             {
                 Type       = ValueType.Array,
                 ArrayValue = actions.ToArray()
             };
             yield return(new TestDef <ActionT>
             {
                 Name = "array(" + string.Join(", ", names) + ")",
                 Encoding = encoding.ToArray(),
                 Actions = new ActionT[] { _valueTestFactory.Value(value, null) }
             });
         }
     }
 }