在 XUNIT 中处理 TargetWithLayout

Dealing with TargetWithLayout in XUNIT

我有一个class,

public class CreateLoggingRuleFactory : ILoggingRuleFactory
{
    public LoggingRule CreateDefaultLoggingRule(string ruleName 
         , LogLevel minimumLevel, LogLevel maximumLevelName,TargetWithLayout targetWithoutStackTrace)
    {
        // blah blah
        var defaultLoggerRule = new LoggingRule(ruleName, minimumLevel targetWithoutStackTrace);
        return defaultLoggerRule;
    }

TargetWithLayout 来自 NLog API.

我想对其进行集成测试。 所以我有一个未完成的代码

 public class CreateLoggingRuleFactorIntegrationTests
{

    [Theory]
    [InlineData(new object[] {"ConsoleLoggerFactory.MyConsoleLogger", LogLevel.Trace,LogLevel.Debug,ClassData(typeof(TargetWithLayout)})]
    public void CreateLoggingRuleFactory_CreateDefaultLogger_Should_Create_LoggingRule_Class()
    {
        // ARRANGE
        var createLoggingRuleFactory = new CreateLoggingRuleFactory();
        var defaultLoggerRule = createLoggingRuleFactory.CreateDefaultLoggingRule
            ();
        Assert.Equal(typeof(LoggingRule), defaultLoggerRule.GetType());
    }

我的问题是我不知道如何将对象 TargetWithLayout 传递给测试方法。

最后我弄明白了。我们需要将 TargetWithLayout Something 的实例作为参数传递给该方法。