public static int Handle(string[] args) { var stopwatch = new Stopwatch(); stopwatch.Start(); var tracer = new ConsoleTraceListener(); try { var options = new Options(); if (CommandLine.Parser.Default.ParseArguments(args, options)) { OnOptionsSuccessful(options, tracer); } else { tracer.WriteLine($"Error in the command line arguments {args.Join(" ")}"); string helpText = CommandLine.Text.HelpText.AutoBuild(new Options()).ToString(); tracer.WriteLine(helpText); } tracer.WriteLine($"Runs in {stopwatch.ElapsedMilliseconds}ms"); return 0; } catch (Exception exception) { tracer.WriteLine(exception.ToString()); return -1; } }
public static void LogToConsole() { /* Create a new console trace listener and add it to the trace listeners. */ ConsoleTraceListener consoletraceListener = new ConsoleTraceListener(); Trace.Listeners.Add(consoletraceListener); Trace.AutoFlush = true; }
/// <summary> /// Main Execution. UI handled in separate method, as this is a procedural utility. /// </summary> /// <param name="args">Not used</param> private static void Main(string[] args) { string serverUrl, destProjectName, plansJSONPath, logPath, csvPath; UIMethod(out serverUrl, out destProjectName, out plansJSONPath, out logPath, out csvPath); teamCollection = new TfsTeamProjectCollection(new Uri(serverUrl)); workItemStore = new WorkItemStore(teamCollection); Trace.Listeners.Clear(); TextWriterTraceListener twtl = new TextWriterTraceListener(logPath); twtl.Name = "TextLogger"; twtl.TraceOutputOptions = TraceOptions.ThreadId | TraceOptions.DateTime; ConsoleTraceListener ctl = new ConsoleTraceListener(false); ctl.TraceOutputOptions = TraceOptions.DateTime; Trace.Listeners.Add(twtl); Trace.Listeners.Add(ctl); Trace.AutoFlush = true; // Get Project ITestManagementTeamProject newTeamProject = GetProject(serverUrl, destProjectName); // Get Test Plans in Project ITestPlanCollection newTestPlans = newTeamProject.TestPlans.Query("Select * From TestPlan"); // Inform user which Collection/Project we'll be working in Trace.WriteLine("Executing alignment tasks in collection \"" + teamCollection.Name + "\",\n\tand Destination Team Project \"" + newTeamProject.TeamProjectName + "\"..."); // Get and print all test case information GetAllTestPlanInfo(newTestPlans, plansJSONPath, logPath, csvPath); Console.WriteLine("Alignment completed. Check log file in:\n " + logPath + "\nfor missing areas or other errors. Press enter to close."); Console.ReadLine(); }
public static void Main(string[] args) { var traceListener = new ConsoleTraceListener(true); Debug.Listeners.Add(traceListener); Debug.AutoFlush = true; var game = new Game( width: 1024, height: 768, mode: new GraphicsMode( color: new ColorFormat(32), depth: 24, stencil: 8, samples: 4 ), title: "DEBUG: Legends of the Universe", options: GameWindowFlags.Default, device: DisplayDevice.Default, major: 4, minor: 0, flags: GraphicsContextFlags.ForwardCompatible | GraphicsContextFlags.Debug ); game.Run(); }
/// <summary> /// Ecrit dans la console le message /// </summary> /// <param name="message">message</param> public static void WriteInConsole(string message) { ConsoleTraceListener consoleTracer; consoleTracer = new ConsoleTraceListener(true); consoleTracer.WriteLine(message); consoleTracer.Close(); }
public TraceLogger(string fileName) { Guard.ArgumentNotEmpty(() => fileName); _traceSource = new TraceSource("SmartStore"); _traceSource.Switch = new SourceSwitch("LogSwitch", "Error"); _traceSource.Listeners.Remove("Default"); var console = new ConsoleTraceListener(false); console.Filter = new EventTypeFilter(SourceLevels.All); console.Name = "console"; var textListener = new TextWriterTraceListener(fileName); textListener.Filter = new EventTypeFilter(SourceLevels.All); textListener.TraceOutputOptions = TraceOptions.DateTime; _traceSource.Listeners.Add(console); _traceSource.Listeners.Add(textListener); // Allow the trace source to send messages to // listeners for all event types. Currently only // error messages or higher go to the listeners. // Messages must get past the source switch to // get to the listeners, regardless of the settings // for the listeners. _traceSource.Switch.Level = SourceLevels.All; }
/// <summary> /// Defines the entry point of the application. /// </summary> /// <remarks>In real life this is going to be a windows service or other type of background operating instance that monitors incomming /// messages. /// Once message is received the handler resumes corresponding flow execution</remarks> /// <param name="args">The arguments.</param> private static void Main(string[] args) { var consoleTracer = new ConsoleTraceListener(true); Trace.Listeners.Add(consoleTracer); using (var queue = new System.Messaging.MessageQueue(@".\private$\tbms.callbackqueue")) { while (true) { Console.WriteLine("Listening..."); var message = queue.Receive(); var bodyReader = new StreamReader(message.BodyStream); var body = bodyReader.ReadToEnd(); var messageBody = (JObject)JsonConvert.DeserializeObject(body); var flowId = messageBody["flowId"].Value<int>(); var flow = DeserializeFlow(flowId); flow?.Resume(); } } }
private static void CreateDebugListener() { return; string LogPath = System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\Viking\\Logs"; if (!Directory.Exists(LogPath)) Directory.CreateDirectory(LogPath); string FileName = LogPath +"\\" + DateTime.Now.ToString("MM.dd.yyyy HH.mm.ss") + ".log"; DebugLogFile = System.IO.File.CreateText(FileName); TextWriter SynchronizedDebugWriter = StreamWriter.Synchronized(DebugLogFile); TextWriterTraceListener Listener = new TextWriterTraceListener(SynchronizedDebugWriter, "Viking Log Listener"); Trace.Listeners.Add(Listener); Debug.Listeners.Add(Listener); ConsoleTraceListener DebugOutputListener = new ConsoleTraceListener(true); Trace.Listeners.Add(DebugOutputListener); Debug.Listeners.Add(DebugOutputListener); Trace.UseGlobalLock = true; }
/// <summary> /// Starts the trace listners. /// </summary> public static void StartTraceListners(string logFilePrefix = "RulePerf") { string logFilePath = "{1}-{0}.log".FormatWith(DateTime.Now.ToString("yyyy-MM-ddThh-mm-ssZ"), logFilePrefix); logFilePath = System.IO.Path.Combine(System.Reflection.Assembly.GetExecutingAssembly().Location, logFilePath); TextWriterTraceListener textWriterTraceListener = new TextWriterTraceListener(logFilePath, "logListener"); ConsoleTraceListener consoleTraceListener = new ConsoleTraceListener(); ////Trace.Listeners.Clear(); if (!Trace.Listeners.Contains(textWriterTraceListener.GetType(), textWriterTraceListener.Name)) { Trace.Listeners.Add(textWriterTraceListener); } else { textWriterTraceListener.Dispose(); } if (!Trace.Listeners.Contains(consoleTraceListener.GetType())) { Trace.Listeners.Add(consoleTraceListener); } else { consoleTraceListener.Dispose(); } Trace.AutoFlush = true; }
// static constructor static DriverTestConfiguration() { var connectionString = CoreTestConfiguration.ConnectionString.ToString(); var mongoUrl = new MongoUrl(connectionString); var clientSettings = MongoClientSettings.FromUrl(mongoUrl); if (!clientSettings.WriteConcern.IsAcknowledged) { clientSettings.WriteConcern = WriteConcern.Acknowledged; // ensure WriteConcern is enabled regardless of what the URL says } var serverSelectionTimeoutString = Environment.GetEnvironmentVariable("MONGO_SERVER_SELECTION_TIMEOUT_MS"); if (serverSelectionTimeoutString == null) { serverSelectionTimeoutString = "10000"; } clientSettings.ServerSelectionTimeout = TimeSpan.FromMilliseconds(int.Parse(serverSelectionTimeoutString)); clientSettings.ClusterConfigurator = cb => { var traceSource = new TraceSource("mongodb-tests", SourceLevels.Information); traceSource.Listeners.Clear(); // remove the default listener var listener = new ConsoleTraceListener(); traceSource.Listeners.Add(listener); cb.TraceWith(traceSource); }; __client = new MongoClient(clientSettings); __databaseNamespace = mongoUrl.DatabaseName == null ? CoreTestConfiguration.DatabaseNamespace : new DatabaseNamespace(mongoUrl.DatabaseName); __collectionNamespace = new CollectionNamespace(__databaseNamespace, "testcollection"); }
public ApiClient(Configuration config) { Configuration = config; RestClient = new RestClient(config.BasePath); TraceListener listener = new System.Diagnostics.ConsoleTraceListener(); Debug.Listeners.Add(listener); }
static void Main(string[] args) { TraceListener listener = new ConsoleTraceListener(); listener.Filter = new EventTypeFilter(SourceLevels.All); Trace.Listeners.Add(listener); EchoServer server = new EchoServer(7); // default any ip, 7 server.Start(); }
public Form1() { ConsoleTraceListener tl = new ConsoleTraceListener(); InitializeComponent(); //_theEnv.AddRouter(new DebugRouter()); _theEnv.Load("test.clp"); _theEnv.Reset(); }
RunTests() { int tests_total = 0; int tests_failed = 0; object[] attrs; // Go through all types Assembly a = Assembly.GetCallingAssembly(); foreach( Type t in a.GetTypes() ) { bool typeprinted = false; // Methods foreach( MethodInfo m in t.GetMethods() ) { // Check for the TestAttribute, indicating a test method attrs = m.GetCustomAttributes( typeof( TestAttribute ), true ); if( attrs.Length <= 0 ) continue; if( !typeprinted ) { Console.WriteLine( t.FullName ); typeprinted = true; } Console.WriteLine(string.Concat(" ", m.Name)); // Run the test bool passed = true; try { ConsoleTraceListener listener = new ConsoleTraceListener(); Debug.Listeners.Add( listener ); m.Invoke( null, null ); Debug.Listeners.Remove( listener ); } catch( TargetInvocationException e ) { TestMessage( TestBase.DumpException( e.InnerException ) ); passed = false; } TestMessage( passed ? "Passed" : "FAILED" ); if( !passed ) tests_failed ++; tests_total++; } } Console.WriteLine( "" ); if( tests_failed > 0 ) { Console.WriteLine( "{0} test{1} failed", tests_failed, (tests_failed == 1 ? "" : "s") ); } else { Console.WriteLine( "All {0} tests passed", tests_total ); } return tests_failed; }
static void Main(string[] args) { var listener = new ConsoleTraceListener(); string url = args.Length == 1 ? args[0] : "http://localhost:91/"; var server = new CacheServer(url); server.Start(); Console.WriteLine("Running cache server on {0}", url); Console.WriteLine("Press 'q' to quit."); Console.WriteLine("Press 'v' to view the cache data."); Console.WriteLine("Press 'd' to enable debug mode."); var uri = new Uri(url); string prompt = String.Format("[{0}:{1}]: ", uri.Host, uri.Port); while (true) { Console.Write(prompt); var ki = Console.ReadKey(); Console.WriteLine(); if (ki.Key == ConsoleKey.Q) { break; } if (ki.Key == ConsoleKey.D) { if (Debug.AutoFlush) { Debug.Listeners.Remove(listener); } else { Debug.Listeners.Add(listener); } Debug.AutoFlush = !Debug.AutoFlush; Log("Turning debugging {0}.", Debug.AutoFlush ? "on" : "off"); } if (ki.Key == ConsoleKey.V) { var entries = server.Store.GetAll().Take(100).ToList(); if (entries.Count == 0) { Log("Nothing in the cache."); } else { foreach (var item in entries) { Console.WriteLine(item.Key + " = " + item.Value); } } } } }
static void Main(string[] args) { // open debug output var tl = new System.Diagnostics.ConsoleTraceListener(); System.Diagnostics.Debug.Listeners.Add ( tl ); Console.WriteLine("begin testing AtomRefManager\n"); AtomRefManager atom = new AtomRefManager(10); int index = atom.allocate(0); atom.setElement(index, 1); int r = (int)atom.getElement(index); Console.WriteLine("end testing ArrayRefManager\n"); Console.WriteLine("begin testing ArrayRefManager\n"); ArrayRefManager arr = new ArrayRefManager(10); int index2 = arr.allocate(2, 0); arr.setElement(index2, 1, 42); int r2 = (int)arr.getElement(index2, 1); Debug.Assert(r2 == 42, "r2 == 42 failed"); int index3 = arr.allocate(3, 0); arr.setElement(index3, 1, 41); int r3 = (int)arr.getElement(index3, 1); Debug.Assert(r3 == 41, "r3 == 41 failed"); Console.WriteLine(arr.ExpressionID); Console.WriteLine(arr.ToString()); Console.WriteLine("end testing ArrayRefManager\n"); Console.WriteLine("begin testing ViewManager\n"); ViewManager vm = new ViewManager(); Maybe opt_rec = vm.get(0, 0, 1, 1); Debug.Assert(!Maybe.is_none(opt_rec), "Fail to get lock."); vm = (ViewManager)vm.GetClone(); Console.WriteLine(vm.ExpressionID); Console.WriteLine(vm.ToString()); opt_rec = vm.get(0, 0, 1, 1); Debug.Assert(Maybe.is_none(opt_rec), "should not get lock."); vm = (ViewManager)vm.GetClone(); Console.WriteLine(vm.ExpressionID); Console.WriteLine(vm.ToString()); opt_rec = vm.get(0, 1, 1, 1); Debug.Assert(!Maybe.is_none(opt_rec), "Fail to get lock."); vm = (ViewManager)vm.GetClone(); Console.WriteLine(vm.ExpressionID); Console.WriteLine(vm.ToString()); Console.WriteLine("end testing ViewManager\n"); }
public static void AssemlyInitialize(TestContext testContext) { AdalTests.TestType = TestType.DotNet; // To record request/response with actual service, switch mode to Record RecorderSettings.Mode = RecorderMode.Replay; ConsoleTraceListener myWriter = new ConsoleTraceListener(); Trace.Listeners.Add(myWriter); }
/// <summary> /// Directs all logging output to the console as well as any other configured log appenders. /// </summary> /// <param name="debugOn"></param> public static void EnableConsoleOutput(bool debugOn) { var consoleListener = new ConsoleTraceListener {TraceOutputOptions = TraceOptions.DateTime}; if (debugOn) { BrightstarTraceSource.Switch.Level = SourceLevels.Verbose; } BrightstarTraceSource.Listeners.Add(consoleListener); }
public static void Init() { traceText = new TextWriterTraceListener("watchdog " + DateTime.Now.Hour + "." + DateTime.Now.Minute + " " + DateTime.Now.Day + "." + DateTime.Now.Month + "." + DateTime.Now.Year); ConsoleTraceListener consoleTrace = new ConsoleTraceListener(false); Trace.Listeners.Add(traceText); Trace.Listeners.Add(consoleTrace); Trace.WriteLine("Init Socket"); comm.Init(); }
public BREFactoryConsole(SourceLevels engineTraceLevel, SourceLevels ruleBaseTraceLevel) { Logger.FlowEngineSource.Switch.Level = engineTraceLevel; Logger.FlowEngineRuleBaseSource.Switch.Level = ruleBaseTraceLevel; Logger.RefreshBooleanSwitches(); ConsoleTraceListener ctl = new ConsoleTraceListener(); Logger.FlowEngineSource.Listeners.Add(ctl); Logger.FlowEngineRuleBaseSource.Listeners.Add(ctl); }
private static void Main(string[] args) { // log to console by default Trace.AutoFlush = true; var traceListener = new ConsoleTraceListener(); traceListener.TraceOutputOptions = TraceOptions.None; Trace.Listeners.Add(traceListener); Parser.RunConsole<App>(args); }
public MainForm() { ConsoleTraceListener tl = new ConsoleTraceListener(); InitializeComponent(); _theEnv.AddRouter(new DebugRouter()); _theEnv.Load("gamedemo.clp"); _theEnv.Reset(); }
static BenchmarkLogging() { TraceSource.Listeners.Remove("Default"); var console = new ConsoleTraceListener(false) { Name = "console", Filter = new EventTypeFilter(SourceLevels.Information) }; TraceSource.Listeners.Add(console); }
static void Main(string[] args) { if (args.Length == 0) PrintUsageAndExit(-1); if (args[0] == "-h") PrintUsageAndExit(0); try { #if DEBUG if (!Debugger.IsAttached) { Console.Error.WriteLine("This is a debug exe."); Console.Error.WriteLine("Do you want to attach the debugger? (y/N)"); var answer = Console.ReadLine(); // I know this looks horrible if (answer.ToLower().StartsWith("y")) { Debugger.Launch(); } Console.Error.WriteLine("Do you want redirect Debug.Print to Console.Error? (y/N)"); answer = Console.ReadLine(); // I know this also looks horrible if (answer.ToLower().StartsWith("y")) { // Redirect Debug.Print/WriteLines to console.error var consoleListener = new ConsoleTraceListener(true); Debug.Listeners.Add(consoleListener); } } #endif // Read file var src = File.ReadAllText(Path.Combine(Environment.CurrentDirectory, args[0])); var app = MtCompiler.CreateScriptApp(Console.OpenStandardOutput()); // Evaluate program var wait = app.Evaluate(src) as MtResult; if (wait == null) { throw new Exception("Evaluate(src) returned null. WTF??"); } // Wait for the end of the program wait.GetValueSync((o) => { }); } catch (Exception e) { PrintExceptionAndExit(e); } }
static void Main() { ConsoleTraceListener console = new ConsoleTraceListener(); Trace.Listeners.Add(console); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Trace.TraceInformation("Console output is here."); ClusterBrowser main = new ClusterBrowser(); Application.Run(main); }
static void Main(string[] args) { var console = new ConsoleTraceListener(); Trace.Listeners.Add(console); try { var arguments = ArgumentParser.Parse(new Arguments("EnvInfo", "Prints Environnment Info", new CommandLineArgument() { Name = "filepath", Switch = "-f", HelpText = "<verbose>", Message = "Please Input a Valid Argument", Required = false }), args); var fp = arguments["filepath"]; if (!string.IsNullOrEmpty(fp)) Trace.Listeners.Add(new TextWriterTraceListener(fp)); for (int i = 0; i < 80; i++) Trace.Write("-"); Trace.WriteLine(Environment.NewLine); Trace.WriteLine(string.Format("Environment Info at {0}", DateTime.Now)); Trace.WriteLine(string.Format("Machine Name : {0}", Environment.MachineName)); Trace.WriteLine(string.Format("OS Version : {0}", Environment.OSVersion.VersionString)); Trace.WriteLine(string.Format("Processor Count : {0}", Environment.ProcessorCount.ToString())); Trace.WriteLine(string.Format("System Directory : {0}", Environment.SystemDirectory)); Trace.WriteLine(string.Format("Current Directory : {0}", Environment.CurrentDirectory)); //Env Variables Trace.WriteLine(string.Empty); Trace.WriteLine("Environment Variables"); foreach (DictionaryEntry envVar in Environment.GetEnvironmentVariables()) Trace.WriteLine(string.Format("{0} : {1}", envVar.Key, envVar.Value)); } catch (Exception ex) { Trace.WriteLine(ex.Message); } Console.WriteLine("Press Enter to continue..."); Trace.Flush(); Console.ReadLine(); }
private void ConnectDiagnosticListeners() { Console.WriteLine("Trying to connect to the System.ServiceModel trace source."); traceListener = new ConsoleTraceListener(false); TraceSource serviceModelTraceSource = new TraceSource("System.ServiceModel"); serviceModelTraceSource.Listeners.Add(traceListener); serviceModelTraceSource.TraceInformation("Test information from the host form \r\n"); TraceSource commonTraceSource = new TraceSource("Tools.Common"); commonTraceSource.Listeners.Add(traceListener); commonTraceSource.TraceInformation("Test information from the Tools.Common \r\n"); }
static void Main(string[] args) { var traceListener = new ConsoleTraceListener(); Debug.Listeners.Add(traceListener); var torrentDefaults = new TorrentSettings(4, 150, 0, 0); torrentDefaults.UseDht = false; var engineSettings = new EngineSettings(); engineSettings.PreferEncryption = false; engineSettings.AllowedEncryption = EncryptionTypes.All; var clientEngine = new ClientEngine(engineSettings); StartDownload(clientEngine, torrentDefaults); }
static void Main(string[] args) { ConsoleTraceListener listener = new ConsoleTraceListener(); Trace.Listeners.Add(listener); SampleClass sampleClass = new SampleClass(); DumpAssemblies(); Trace.Write("Press any key to exit"); Console.ReadKey(); Trace.Listeners.Remove(listener); }
// Please set the following connection strings in app.config for this WebJob to run: // AzureWebJobsDashboard and AzureWebJobsStorage static void Main() { TraceListener listener = new ConsoleTraceListener(); listener.Filter = new EventTypeFilter(SourceLevels.All); Trace.Listeners.Add(listener); Trace.TraceInformation("Server started"); UdpListenerClient server = new UdpListenerClient(7000); // default any ip, 7 string receievedstring = server.Start(); httpClient serverHttp = new httpClient(); serverHttp.StartHttp(receievedstring).Wait(); var host = new JobHost(); // The following code ensures that the WebJob will be running continuously host.RunAndBlock(); }
public static void InitializeLogging() { lock (LOCK) { if (!_initialized) { ConsoleTraceListener listener = new ConsoleTraceListener(); listener.TraceOutputOptions = TraceOptions.ThreadId | TraceOptions.Timestamp; Trace.Listeners.Add(listener); _initialized = true; } } }
static async Task Proc() { using (var logStrm = new System.IO.StreamWriter(@".\trace.log", false) { AutoFlush = true }) using (var loggerA = new System.Diagnostics.DelimitedListTraceListener(logStrm)) using (var loggerB = new System.Diagnostics.ConsoleTraceListener()) { System.Diagnostics.Trace.Listeners.Add(loggerA); System.Diagnostics.Trace.Listeners.Add(loggerB); Trace.WriteLine("------------------------------"); Trace.WriteLine(" Environment"); Trace.WriteLine("------------------------------"); Trace.WriteLine(string.Format("Environment.OSVersion: {0}", Environment.OSVersion)); Trace.WriteLine(string.Format("Environment.Is64BitOperatingSystem: {0}", Environment.Is64BitOperatingSystem)); Trace.WriteLine(string.Format("Environment.Is64BitProcess: {0}", Environment.Is64BitProcess)); Console.WriteLine(); Trace.WriteLine("------------------------------"); Trace.WriteLine(" Tests: IE"); Trace.WriteLine("------------------------------"); var targetUrl = new Uri("http://nicovideo.jp"); var valueKey = null as string; try { //Win32Api.IEGetProtectedModeCookie string lpszCookieData; var hResult = Win32Api.GetCookiesFromProtectedModeIE(out lpszCookieData, targetUrl, valueKey); Trace.WriteLine(lpszCookieData != null ? string.Format("Win32Api.GetCookieFromProtectedModeIE success: 0x{0}", hResult.ToString("x8")) : string.Format("Win32Api.GetCookieFromProtectedModeIE error: 0x{0}", hResult.ToString("x8"))); } catch (Exception e) { Trace.WriteLine(e); } finally { Trace.WriteLine(string.Empty); } try { //Win32Api.IEGetProtectedModeCookie (No Flags) string lpszCookieData; var hResult = Win32Api.GetCookiesFromProtectedModeIE(out lpszCookieData, targetUrl, valueKey, 0); Trace.WriteLine(lpszCookieData != null ? string.Format("Win32Api.GetCookieFromProtectedModeIE(no flags) success: 0x{0}", hResult.ToString("x8")) : string.Format("Win32Api.GetCookieFromProtectedModeIE(no flags) error: 0x{0}", hResult.ToString("x8"))); } catch (Exception e) { Trace.WriteLine(e); } finally { Trace.WriteLine(string.Empty); } try { //IEPMCookieImporter.InternalGetCookiesWinApiOnProxy if (Environment.OSVersion.Platform == PlatformID.Win32NT) { var cookieHeader = IEPMCookieImporter.InternalGetCookiesWinApiOnProxy(targetUrl, valueKey); Trace.WriteLine(cookieHeader != null ? string.Format("IEPMCookieImporter.InternalGetCookiesWinApiOnProxy success") : string.Format("IEPMCookieImporter.InternalGetCookiesWinApiOnProxy error")); } } catch (Exception e) { Trace.WriteLine(e); } finally { Trace.WriteLine(string.Empty); } try { //IEEPMCookieImporter if (Environment.OSVersion.Platform == PlatformID.Win32NT) { var importer = new IEImporterFactory().GetIEEPMCookieImporter(); var res = await importer.GetCookiesAsync(targetUrl); Trace.WriteLine(res.Status == CookieImportState.Success && res.Cookies.Count > 0 ? string.Format("IEEPMCookieImporter success") : string.Format("IEEPMCookieImporter error")); } } catch (Exception e) { Trace.WriteLine(e); } finally { Trace.WriteLine(string.Empty); } Console.WriteLine(); Trace.WriteLine("------------------------------"); Trace.WriteLine(" Tests: CookieGetters"); Trace.WriteLine("------------------------------"); try { var getters = await CookieGetters.Default.GetInstancesAsync(false); Trace.WriteLine(string.Format("Browser.Length: {0}", getters.Length)); for (var i = 0; i < getters.Length; i++) { try { Trace.WriteLine(string.Format("{0:00}: {1}", i, getters[i].SourceInfo.BrowserName)); Trace.Indent(); var res = await getters[i].GetCookiesAsync(targetUrl); Trace.WriteLine(string.Format("Status: {0}", res.Status)); Trace.WriteLine(string.Format("Cookies.Count: {0}", res.Status == CookieImportState.Success ? res.Cookies.Count.ToString() : "None")); Trace.Unindent(); } catch (Exception e) { Trace.WriteLine(e); } } } catch (Exception e) { Trace.WriteLine(e); } } }
/// <summary> /// start a self- / box-test for some diff cases and report to the debug output. /// </summary> /// <param name="args">not used</param> /// <returns>always 0</returns> public static int Main(string[] args) { StringBuilder ret = new StringBuilder(); string a, b; System.Diagnostics.ConsoleTraceListener ctl = new System.Diagnostics.ConsoleTraceListener(false); System.Diagnostics.Debug.Listeners.Add(ctl); System.Console.WriteLine("Diff Self Test..."); // test all changes a = "a,b,c,d,e,f,g,h,i,j,k,l".Replace(',', '\n'); b = "0,1,2,3,4,5,6,7,8,9".Replace(',', '\n'); System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false)) == "12.10.0.0*", "all-changes test failed."); System.Diagnostics.Debug.WriteLine("all-changes test passed."); // test all same a = "a,b,c,d,e,f,g,h,i,j,k,l".Replace(',', '\n'); b = a; System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false)) == "", "all-same test failed."); System.Diagnostics.Debug.WriteLine("all-same test passed."); // test snake a = "a,b,c,d,e,f".Replace(',', '\n'); b = "b,c,d,e,f,x".Replace(',', '\n'); System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false)) == "1.0.0.0*0.1.6.5*", "snake test failed."); System.Diagnostics.Debug.WriteLine("snake test passed."); // 2002.09.20 - repro a = "c1,a,c2,b,c,d,e,g,h,i,j,c3,k,l".Replace(',', '\n'); b = "C1,a,C2,b,c,d,e,I1,e,g,h,i,j,C3,k,I2,l".Replace(',', '\n'); System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false)) == "1.1.0.0*1.1.2.2*0.2.7.7*1.1.11.13*0.1.13.15*", "repro20020920 test failed."); System.Diagnostics.Debug.WriteLine("repro20020920 test passed."); // 2003.02.07 - repro a = "F".Replace(',', '\n'); b = "0,F,1,2,3,4,5,6,7".Replace(',', '\n'); System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false)) == "0.1.0.0*0.7.1.2*", "repro20030207 test failed."); System.Diagnostics.Debug.WriteLine("repro20030207 test passed."); // Muegel - repro a = "HELLO\nWORLD"; b = "\n\nhello\n\n\n\nworld\n"; System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false)) == "2.8.0.0*", "repro20030409 test failed."); System.Diagnostics.Debug.WriteLine("repro20030409 test passed."); // test some differences a = "a,b,-,c,d,e,f,f".Replace(',', '\n'); b = "a,b,x,c,e,f".Replace(',', '\n'); System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false)) == "1.1.2.2*1.0.4.4*1.0.7.6*", "some-changes test failed."); System.Diagnostics.Debug.WriteLine("some-changes test passed."); // test one change within long chain of repeats a = "a,a,a,a,a,a,a,a,a,a".Replace(',', '\n'); b = "a,a,a,a,-,a,a,a,a,a".Replace(',', '\n'); System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false)) == "0.1.4.4*1.0.9.10*", "long chain of repeats test failed."); System.Diagnostics.Debug.WriteLine("End."); System.Diagnostics.Debug.Flush(); return(0); }