public void An_MDS_incoming_and_outgoing_pointers_is_parsed_correctly()
            {
                var factory = new Mock <IMdsDescriptorFactory>(MockBehavior.Strict);

                factory.Setup(t => t.Add(1, new int[0], 2));
                factory.Setup(t => t.Create()).Returns((IMdsDescriptor)null);
                MdsDescriptorParser.Parse("(1,2)", factory.Object);
                factory.VerifyAll();
            }
            public void An_MDS_with_content_is_parsed_correctly()
            {
                var factory = new Mock <IMdsDescriptorFactory>(MockBehavior.Strict);

                factory.Setup(t => t.Add(1, new[] { 2, 3 }, 4));
                factory.Setup(t => t.Create()).Returns((IMdsDescriptor)null);
                MdsDescriptorParser.Parse("(1,2,3,4)", factory.Object);
                factory.VerifyAll();
            }
            public void Variable_pointers_are_parsed_correctly()
            {
                var factory = new Mock <IMdsDescriptorFactory>(MockBehavior.Strict);

                factory.Setup(t => t.Add(Pointer.End - 1, new int[0], Pointer.End - 2));
                factory.Setup(t => t.Add(1, new [] { Pointer.End - 1 }, -(Pointer.End - 2)));
                factory.Setup(t => t.Create()).Returns((IMdsDescriptor)null);
                MdsDescriptorParser.Parse("(x,y)(1,x,-y)", factory.Object);
                factory.VerifyAll();
            }
            public void End_pointer_is_parsed_correctly()
            {
                var factory = new Mock <IMdsDescriptorFactory>(MockBehavior.Strict);

                factory.Setup(t => t.Add(1, new[] { 2 }, Pointer.End));
                factory.Setup(t => t.Add(4, new int[0], 5));
                factory.Setup(t => t.Create()).Returns((IMdsDescriptor)null);
                MdsDescriptorParser.Parse("(1,2,e)(4,5)", factory.Object);
                factory.VerifyAll();
            }
Пример #5
0
        static int Main(string[] args)
        {
            var opts = new ConsoleOptions(args);

            if (opts.ParameterCount > 1)
            {
                opts.Help();
                return(1);
            }

            var counts   = new CountingRecorder();
            var recorder = counts;
            //var logger = new TraceLogger(counts,Console.Out);

            var assembler = new StrategyEnumerator(recorder);

            if (!(opts.ld || opts.hi || opts.dlad))
            {
                assembler.LdIsAllowed   = true;
                assembler.HiIsAllowed   = true;
                assembler.DladIsAllowed = true;
            }
            else
            {
                assembler.LdIsAllowed   = opts.ld;
                assembler.HiIsAllowed   = opts.hi;
                assembler.DladIsAllowed = opts.dlad;
            }
            string descriptorString;

            if (opts.ParameterCount == 1)
            {
                descriptorString = opts.Parameters[0] as string;
            }
            else if (!String.IsNullOrEmpty(opts.file))
            {
                descriptorString = File.ReadAllText(opts.file);
            }
            else
            {
                descriptorString = Console.ReadLine();
            }
            assembler.Enumerate(MdsDescriptorParser.Parse(descriptorString));

            Console.Out.WriteLine("Successful: {0}", counts.Successful);
            Console.Out.WriteLine("Total:      {0}", counts.Total);

            return(0);
        }
 static LinqMdsDescriptor Parse(string str)
 {
     return((LinqMdsDescriptor)MdsDescriptorParser.Parse(str, new LinqMdsDescriptorFactory()));
 }