~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/monomac/samples/CFNetwork/AsyncTests.Console/Main.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using System;
 
2
using System.IO;
 
3
using System.Diagnostics;
 
4
using System.Threading;
 
5
using System.Threading.Tasks;
 
6
using System.Reflection;
 
7
using System.Xml;
 
8
using System.Xml.Serialization;
 
9
using AsyncTests.HttpClientAddin;
 
10
using NDesk.Options;
 
11
 
 
12
namespace AsyncTests.ConsoleRunner
 
13
{
 
14
        using Framework;
 
15
 
 
16
        class MainClass
 
17
        {
 
18
                static bool xml;
 
19
 
 
20
                public static void Main (string[] args)
 
21
                {
 
22
                        Debug.AutoFlush = true;
 
23
                        Debug.Listeners.Add (new ConsoleTraceListener ());
 
24
 
 
25
                        bool server = false;
 
26
                        string prefix = "http://localhost:8088/";
 
27
                        var p = new OptionSet ().
 
28
                                Add ("server", v => server = true).Add ("prefix=", v => prefix = v).
 
29
                                        Add ("xml", v => xml = true);
 
30
                        p.Parse (args);
 
31
 
 
32
                        var asm = typeof(AsyncTests.HttpClientTests.Simple).Assembly;
 
33
 
 
34
                        if (server) {
 
35
                                Server.Start (asm, prefix).Wait ();
 
36
                                Thread.Sleep (Timeout.Infinite);
 
37
                                return;
 
38
                        }
 
39
 
 
40
                        try {
 
41
                                Run (asm).Wait ();
 
42
                        } catch (Exception ex) {
 
43
                                Console.WriteLine ("ERROR: {0}", ex);
 
44
                        }
 
45
                }
 
46
 
 
47
                static async Task Run (Assembly assembly)
 
48
                {
 
49
                        var suite = await TestSuite.Create (assembly);
 
50
                        var results = await suite.Run (CancellationToken.None);
 
51
                        WriteResults (results);
 
52
                }
 
53
 
 
54
                static void WriteResults (TestResultCollection results)
 
55
                {
 
56
                        if (xml) {
 
57
                                var serializer = new XmlSerializer (typeof(TestResultCollection));
 
58
                                serializer.Serialize (Console.Out, results);
 
59
                                Console.WriteLine ();
 
60
                        } else {
 
61
                                ResultPrinter.Print (Console.Out, results);
 
62
                        }
 
63
                }
 
64
        }
 
65
}