public TestDef <ActionT> Then(TestDef <ActionT> next)
 {
     return(new TestDef <ActionT>
     {
         Name = this.Name + ", " + next.Name,
         Encoding = Encoding.Concat(next.Encoding),
         Actions = Actions.Concat(next.Actions)
     });
 }
        public IEnumerable <TestDef <ActionT> > MakeAllValueTests()
        {
            var eofTest = new TestDef <ActionT>
            {
                Name     = "EOF",
                Encoding = new string[0],
                Actions  = new ActionT[] { _valueTestFactory.EOF() }
            };
            var tests = MakeScalarValueTests(true)
                        .Concat(MakeArrayTests())
                        .Concat(MakeObjectTests());

            foreach (var td in tests)
            {
                yield return(td.Then(eofTest));
            }
        }
        public IEnumerable <TestDef <ActionT> > MakeScalarValueTests(bool allPermutations)
        {
            var values = new List <ValueTest <ActionT> >();

            values.Add(new ValueTest <ActionT>
            {
                Name     = "null",
                Encoding = "null",
                Value    = new TestValue <ActionT> {
                    Type = ValueType.Null
                }
            });
            values.AddRange(ValueTests <ActionT> .MakeBools());
            values.AddRange(ValueTests <ActionT> .MakeNumbers(_encodingBehavior));
            values.AddRange(ValueTests <ActionT> .MakeStrings(_encodingBehavior, allPermutations));

            foreach (var vt in values)
            {
                var variants = _valueTestFactory.Variants(vt.Value);
                if (variants == null)
                {
                    variants = new ValueVariant[] { null };
                }
                foreach (var variant in variants)
                {
                    var td = new TestDef <ActionT>
                    {
                        Name = variant == null ? vt.Name :
                               (variant.ToString() + " " + vt.Name),
                        Encoding = new string[] { vt.Encoding },
                        Actions  = new ActionT[] { _valueTestFactory.Value(vt.Value, variant) }
                    };
                    yield return(td);
                }
            }
        }