コード例 #1
0
ファイル: TapEntry.cs プロジェクト: ZHJEE/OpenTAP
        private static void goInProcess()
        {
            var start = DateTime.Now;

            void loadCommandLine()
            {
                var  args      = Environment.GetCommandLineArgs();
                bool isVerbose = args.Contains("--verbose") || args.Contains("-v");
                bool isQuiet   = args.Contains("--quiet");
                bool isColor   = args.Contains("--color") || args.Contains("-c");

                ConsoleTraceListener.SetStartupTime(start);
                var cliTraceListener = new ConsoleTraceListener(isVerbose, isQuiet, isColor);

                Log.AddListener(cliTraceListener);
                cliTraceListener.TraceEvents(TapInitializer.InitTraceListener.Instance.AllEvents.ToArray());
                AppDomain.CurrentDomain.ProcessExit += (s, e) => cliTraceListener.Flush();
            }

            TapInitializer.Initialize(); // This will dynamically load OpenTap.dll
            // loadCommandLine has to be called after Initialize
            // to ensure that we are able to load OpenTap.dll
            loadCommandLine();
            wrapGoInProcess();
        }
コード例 #2
0
        public static void StartConsoleActivity(this IActivity activity, ProgramArgs args, TraceSource traceSource)
        {
            using (var listener = new ConsoleTraceListener())
            {
                traceSource?.Listeners.Add(listener);

                try
                {
                    activity.Start(args);
                }
                finally
                {
                    listener.Flush();
                }
            }
        }
コード例 #3
0
        public void ConsoleTraceListener_BasicVerification()
        {
            var expectedText = Guid.NewGuid().ToString();

            using (var memoryStream = new MemoryStream())
                using (var textWriter = new StreamWriter(memoryStream))
                    using (var listener = new ConsoleTraceListener(textWriter))
                    {
                        listener.WriteLine(expectedText);
                        listener.Flush();
                        textWriter.Flush();
                        var buf        = memoryStream.ToArray();
                        var actualText = Encoding.UTF8.GetString(buf, 0, buf.Length);
                        Assert.IsTrue(actualText.Contains(expectedText));
                    }
        }
コード例 #4
0
	public void WhenExecutingRequest_ThenTracesInformationHeaders()
	{
		var listener = new ConsoleTraceListener();
		TracerExtensibility.AddListener(SourceName.For<TracingChannel>(), listener);
		TracerExtensibility.SetTracingLevel(SourceName.For<TracingChannel>(), SourceLevels.All);

		var config = HttpHostConfiguration.Create()
			.UseJsonNet()
			.AddMessageHandlers(typeof(TracingChannel));

		using (var ws = new HttpWebService<TestService>("http://localhost:20000", "products", true, config))
		{
			var client = new HttpEntityClient(ws.BaseUri);
			var products = client.Query<Product>().Skip(1).Take(1).ToList();

			Assert.Equal(1, products.Count);
			Assert.Equal(2, products[0].Id);
		}

		listener.Flush();
	}
コード例 #5
0
    public void WhenExecutingRequest_ThenTracesInformationHeaders()
    {
        var listener = new ConsoleTraceListener();

        TracerExtensibility.AddListener(SourceName.For <TracingChannel>(), listener);
        TracerExtensibility.SetTracingLevel(SourceName.For <TracingChannel>(), SourceLevels.All);

        var config = HttpHostConfiguration.Create()
                     .UseJsonNet()
                     .AddMessageHandlers(typeof(TracingChannel));

        using (var ws = new HttpWebService <TestService>("http://localhost:20000", "products", true, config))
        {
            var client   = new HttpEntityClient(ws.BaseUri);
            var products = client.Query <Product>().Skip(1).Take(1).ToList();

            Assert.Equal(1, products.Count);
            Assert.Equal(2, products[0].Id);
        }

        listener.Flush();
    }