public static void SetupClass(TestContext context) { //publish database first by running the batch file; comment this out if already published and no further updates var p = new Process(); var startInfo = new ProcessStartInfo { WorkingDirectory = ".\\..\\..\\..\\", FileName = "PublishSampleDb.bat", CreateNoWindow = false, }; p.StartInfo = startInfo; p.Start(); p.WaitForExit(); //reset mef (settings) in case the other test classes used it and initialized its static data in a specific way new Mef(); //setup logger (resolve) Log = LogResolver.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); if (Log == null) { Assert.Fail("Logger not found. Check configuration."); } Log.Debug("Unit Test Class SETUP OK"); }
public void Test() { string log = File.ReadAllText("input.txt"); LogEntity entity; Assert.True(LogResolver.TryResolve(log, out entity)); }
static EntityMapper() { try { Log = LogResolver.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); }catch (Exception e) { WriteLine($"Logger could not be resolved. Will continue without logging. INitialization exception: {e.Message}"); } }
private static ILogger ResolveLogger() { try { return(LogResolver.GetLogger(MethodBase.GetCurrentMethod().DeclaringType)); } catch (Exception e) { Debug.WriteLine($"Logger could not be resolved. Will continue without logging. INitialization exception: {e.Message}"); } return(default);
static CacheManager() { try { Log = LogResolver.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); } catch (Exception ex) { Debug.WriteLine($"No logger implementation found. Will not log details. {ex.Message}"); } }
static ExecuteMethodTemplates() { try { Logger = LogResolver.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); } catch (Exception e) { Debug.WriteLine($"Logger could not be resolved. Will continue without logging. INitialization exception: {e.Message}"); } }
public static void CleanupClass() { Log.Debug("Unit Test Class CLEANUP in progress."); //stop logger if exists LogResolver.CloseLogger(); if (Directory.Exists("log")) { Directory.Delete("log", true); } }
public override void Cleanup() { base.Cleanup(); LogResolver.CloseLogger(); //shut down logger before deleting the log directory //delete any log files created by the test if (Directory.Exists(LogFolder)) { Directory.GetFiles(LogFolder).ForEach(f => File.Delete(f)); } }
/// <summary> /// Simple helper to initialize Log4Net within Splat with the Wrapping Full Logger. /// </summary> /// <remarks> /// You should configure Log4Net prior to calling this method. /// </remarks> /// <param name="instance"> /// An instance of Mutable Dependency Resolver. /// </param> /// <example> /// <code> /// Locator.CurrentMutable.UseLog4NetWithWrappingFullLogger(); /// </code> /// </example> public static void UseLog4NetWithWrappingFullLogger(this IMutableDependencyResolver instance) { var funcLogManager = new FuncLogManager(type => new WrappingFullLogger(new Log4NetLogger(LogResolver.Resolve(type)))); instance.RegisterConstant(funcLogManager, typeof(ILogManager)); }
internal static void CoreWrite() { while (_running || _logs.Count > 0) { List <string> _temp = null; try { int loop = _logs.Count > 5000 ? 5000 : _logs.Count; if (loop == 0) { Thread.Sleep(1000); continue; } List <LogEntity> entities = new List <LogEntity>(); List <string> _error = new List <string>(); _temp = new List <string>(); for (int i = 0; i < loop; i++) { if (_logs.TryDequeue(out var log) && !string.IsNullOrEmpty(log)) { if (LogResolver.TryResolve(log, out var entity) && entity != null) { entities.Add(entity); _temp.Add(log); } else { _error.Add(log); } } else { Console.WriteLine("Dequeue error."); } } if (_error.Count >= 0) { File.AppendAllLines("_resolve.err.nut", _error); _error.Clear(); _error = null; } if (entities.Count > 0) { try { _write(entities); } catch { for (int i = 0; i < _temp.Count; i++) { _logs.Enqueue(_temp[i]); } _temp.Clear(); _temp = null; throw; } finally { entities.Clear(); entities = null; } } _temp.Clear(); _temp = null; if (loop >= 5000) { Thread.Sleep(1000); } else { Thread.Sleep(3000); } }