Example #1
0
    public SerilogTests()
    {
        AppDomainAssemblyFinder.Attach();
        beforeAssemblyPath = Path.GetFullPath(@"..\..\..\SerilogAssemblyToProcess\bin\Debug\SerilogAssemblyToProcess.dll");
#if (!DEBUG)
        beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
        afterAssemblyPath = WeaverHelper.Weave(beforeAssemblyPath);
        assembly          = Assembly.LoadFile(afterAssemblyPath);
    }
Example #2
0
    public CustomTests()
    {
        AppDomainAssemblyFinder.Attach();
        beforeAssemblyPath = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\CustomAssemblyToProcess\bin\Debug\CustomAssemblyToProcess.dll"));
#if (!DEBUG)
        beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
        afterAssemblyPath = WeaverHelper.Weave(beforeAssemblyPath);
        assembly          = Assembly.LoadFile(afterAssemblyPath);
    }
Example #3
0
    public GenericExternalTests()
    {
        AppDomainAssemblyFinder.Attach();
        var beforeAssemblyPath = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\WithGenericExternal\bin\Debug\WithGenericExternal.dll"));

#if (!DEBUG)
        beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
        afterAssemblyPath = WeaverHelper.Weave(beforeAssemblyPath);
        assembly          = Assembly.LoadFile(afterAssemblyPath);
    }
    public NonGenericExternalTests()
    {
        AppDomainAssemblyFinder.Attach();
        var beforeAssemblyPath = Path.GetFullPath(@"..\..\..\WithNonGenericExternal\bin\Debug\WithNonGenericExternal.dll");

#if (!DEBUG)
        beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
        afterAssemblyPath = WeaverHelper.Weave(beforeAssemblyPath);
        assembly          = Assembly.LoadFile(afterAssemblyPath);
    }
Example #5
0
    public NServiceBusTests()
    {
        AppDomainAssemblyFinder.Attach();
        beforeAssemblyPath = Path.GetFullPath(@"..\..\..\NServiceBusAssemblyToProcess\bin\Debug\NServiceBusAssemblyToProcess.dll");
#if (!DEBUG)
        beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
        afterAssemblyPath = WeaverHelper.Weave(beforeAssemblyPath);
        assembly          = Assembly.LoadFile(afterAssemblyPath);

        LogManager.UseFactory(new LogCapture(this));
    }
Example #6
0
    public CommonLoggingTests()
    {
        AppDomainAssemblyFinder.Attach();
        beforeAssemblyPath = Path.GetFullPath(@"..\..\..\CommonLoggingAssemblyToProcess\bin\Debug\CommonLoggingAssemblyToProcess.dll");
#if (!DEBUG)
        beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
        afterAssemblyPath  = WeaverHelper.Weave(beforeAssemblyPath);
        assembly           = Assembly.LoadFile(afterAssemblyPath);
        actionAdapter      = new ActionAdapter();
        LogManager.Adapter = actionAdapter;
    }
Example #7
0
    public SplatTests()
    {
        AppDomainAssemblyFinder.Attach();
        beforeAssemblyPath = Path.GetFullPath(@"..\..\..\SplatAssemblyToProcess\bin\Debug\SplatAssemblyToProcess.dll");
#if (!DEBUG)
        beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
        afterAssemblyPath = WeaverHelper.Weave(beforeAssemblyPath);
        assembly          = Assembly.LoadFile(afterAssemblyPath);

        Locator.CurrentMutable.Register(() => new FuncLogManager(GetLogger), typeof(ILogManager));
    }
Example #8
0
    public LibLogTests()
    {
        AppDomainAssemblyFinder.Attach();
        beforeAssemblyPath = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\LibLogAssemblyToProcess\bin\Debug\LibLogAssemblyToProcess.dll"));
#if (!DEBUG)
        beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
        afterAssemblyPath = WeaverHelper.Weave(beforeAssemblyPath);
        assembly          = Assembly.LoadFile(afterAssemblyPath);

        logProvider = new LogCapture();
        LogProvider.SetCurrentLogProvider(logProvider);
    }
Example #9
0
    public CatelTests()
    {
        AppDomainAssemblyFinder.Attach();
        beforeAssemblyPath = Path.GetFullPath(@"..\..\..\CatelAssemblyToProcess\bin\Debug\CatelAssemblyToProcess.dll");
#if (!DEBUG)
        beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
        afterAssemblyPath = WeaverHelper.Weave(beforeAssemblyPath);
        assembly          = Assembly.LoadFile(afterAssemblyPath);
        LogManager.AddListener(new LogListener
        {
            Action = LogMessage
        });
    }
Example #10
0
    protected CatelTests(string assemblyName)
    {
        AppDomainAssemblyFinder.Attach();
        beforeAssemblyPath = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory, $@"..\..\..\{assemblyName}\bin\Debug\CatelAssemblyToProcess.dll"));
#if (!DEBUG)
        beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
        afterAssemblyPath = WeaverHelper.Weave(beforeAssemblyPath);
        assembly          = Assembly.LoadFile(afterAssemblyPath);

        LogManager.AddListener(new LogListener
        {
            Action = LogMessage
        });
    }
    private void WeaveAssembly(string target)
    {
        lock (weaverLock)
        {
            if (assemblies.ContainsKey(target) == false)
            {
                AppDomainAssemblyFinder.Attach();
                var assemblyPathUri    = new Uri(new Uri(typeof(TestAssemblies).GetTypeInfo().Assembly.CodeBase), $"../../../../{assemblyToProcessName}/bin/Debug/{target}/{assemblyToProcessName}.dll");
                var beforeAssemblyPath = Path.GetFullPath(assemblyPathUri.LocalPath);
#if (!DEBUG)
                beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
                var afterAssemblyPath = WeaverHelper.Weave(beforeAssemblyPath);
                assemblies[target] = Tuple.Create(Assembly.LoadFile(afterAssemblyPath), beforeAssemblyPath, afterAssemblyPath);
            }
        }
    }
Example #12
0
    public CommonLoggingTests()
    {
#if (PORTABLE)
        var path = Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\CommonLoggingAssemblyToProcessPortable\bin\Debug\CommonLoggingAssemblyToProcessPortable.dll");
#else
        var path = Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\CommonLoggingAssemblyToProcess\bin\Debug\CommonLoggingAssemblyToProcess.dll");
#endif
        AppDomainAssemblyFinder.Attach();
        beforeAssemblyPath = Path.GetFullPath(path);
#if (!DEBUG)
        beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
        afterAssemblyPath  = WeaverHelper.Weave(beforeAssemblyPath);
        assembly           = Assembly.LoadFile(afterAssemblyPath);
        actionAdapter      = new ActionAdapter();
        LogManager.Adapter = actionAdapter;
    }
Example #13
0
    public Log4NetTests()
    {
        AppDomainAssemblyFinder.Attach();
        beforeAssemblyPath = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\Log4NetAssemblyToProcess\bin\Debug\Log4NetAssemblyToProcess.dll"));
#if (!DEBUG)
        beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
        afterAssemblyPath = WeaverHelper.Weave(beforeAssemblyPath);
        assembly          = Assembly.LoadFile(afterAssemblyPath);
        var hierarchy = (Hierarchy)LogManager.GetRepository();
        hierarchy.Root.RemoveAllAppenders();

        var target = new ActionAppender
        {
            Action = LogEvent
        };
        BasicConfigurator.Configure(target);
    }
Example #14
0
    private Assembly WeaveAssembly(string target)
    {
        lock (weaverLock)
        {
            if (assemblies.ContainsKey(target) == false)
            {
                AppDomainAssemblyFinder.Attach();
                var assemblyPathUri = new Uri(new Uri(typeof(CustomTests).GetTypeInfo().Assembly.CodeBase), $"../../../../CustomAssemblyToProcess/bin/Debug/{target}/CustomAssemblyToProcess.dll");
                beforeAssemblyPath = Path.GetFullPath(assemblyPathUri.LocalPath);
#if (!DEBUG)
                beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
                afterAssemblyPath  = WeaverHelper.Weave(beforeAssemblyPath, target);
                assemblies[target] = Assembly.LoadFile(afterAssemblyPath);
            }

            return(assemblies[target]);
        }
    }
Example #15
0
    public NLogTests()
    {
        AppDomainAssemblyFinder.Attach();
        beforeAssemblyPath = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\NLogAssemblyToProcess\bin\Debug\NLogAssemblyToProcess.dll"));
#if (!DEBUG)
        beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
        afterAssemblyPath = WeaverHelper.Weave(beforeAssemblyPath);
        assembly          = Assembly.LoadFile(afterAssemblyPath);
        var config = new LoggingConfiguration();
        var target = new ActionTarget
        {
            Action = LogEvent
        };

        config.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, target));
        config.AddTarget("debugger", target);
        LogManager.Configuration = config;
    }
Example #16
0
    public MetroLogTests()
    {
        AppDomainAssemblyFinder.Attach();
        var configuration = LogManagerFactory.DefaultConfiguration;

        configuration.IsEnabled = true;
        beforeAssemblyPath      = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\MetroLogAssemblyToProcess\bin\Debug\MetroLogAssemblyToProcess.dll"));
#if (!DEBUG)
        beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
        afterAssemblyPath = WeaverHelper.Weave(beforeAssemblyPath);
        assembly          = Assembly.LoadFile(afterAssemblyPath);
        var target = new ActionTarget
        {
            Action = LogEvent
        };

        configuration.AddTarget(LogLevel.Trace, target);
        configuration.AddTarget(LogLevel.Debug, target);
        configuration.AddTarget(LogLevel.Warn, target);
        configuration.AddTarget(LogLevel.Info, target);
        configuration.AddTarget(LogLevel.Error, target);
        configuration.AddTarget(LogLevel.Fatal, target);
    }
Example #17
0
 public static void Initialize()
 {
     AppDomainAssemblyFinder.Attach();
 }