Пример #1
0
        static void Run(CommandLineOptions options)
        {
            if (options.CreatorType == CreatorType.StronglyTyped)
            {
                // Register all the class maps in this assembly (Person and Address objects in Sample namespace)
                MapRegistrar.Register(Assembly.GetExecutingAssembly());
            }
            //else
            //{
            //    if (options.OutputType == OutputType.Xml)
            //    {
            //        Console.WriteLine("Error: Cannot use Xml output with dynamic object creation, add -c StronglyTyped to the command line arguments.");
            //        return;
            //    }
            //}

            using (IDataSource ds = DataSourceFactory.Create(options.DataSourceType))
            {
                ds.Initialise(options.DataSource);

                dynamic people = null;

                //if (options.OutputType == OutputType.Xml)
                //{
                //    // Bit hacky this, but need to use strongly typed objects for Xml serialisation
                //    people = CreatorFactory.Create<Person>(options.CreatorType)
                //        .GetObjects(ds).Cast<Person>().ToArray();
                //}
                //else
                //{
                //    people = CreatorFactory.Create<Person>(options.CreatorType)
                //        .GetObjects(ds);
                //}

                people = CreatorFactory.Create <Person>(options.CreatorType)
                         .GetObjects(ds);

                var outputter = OutputFactory.Create <Person>(options.OutputType);

                Console.WriteLine(outputter.Output(people));
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            ArgsResult argsResult = ParseArgs(args);

            if (argsResult.IsHelp)
            {
                Console.WriteLine("Help:");
                Console.WriteLine("Use 2 arguments. First argument is path of config file, second argument is path of result test");
                Console.WriteLine("Example:");
                Console.WriteLine("\tRestTest.ConsoleApp C:\\\\folder\\config.json .\\result.json");

                Console.ReadKey();
                return;
            }

            var     factory = new OutputFactory();
            IOutput output  = factory.Create(argsResult);

            try
            {
                RT rt = new RT(argsResult.ConfigPath);
                rt.OnTestFinished += output.OnTestFinished;
                rt.Start();
                output.AllTestsFinished();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
            finally
            {
                if (!argsResult.ContinueAfterFinished)
                {
                    Console.ReadKey();
                }
            }
        }