public void Should_Add_Logger() { // Given var settings = new DotNetCoreMSBuildSettings(); var fileLogger = new MSBuildFileLoggerSettings(); var fileLogger2 = new MSBuildFileLoggerSettings() { LogFile = "A" }; // When settings.AddFileLogger(fileLogger); settings.AddFileLogger(fileLogger2); // Then var loggers = settings.FileLoggers.ToArray(); Assert.Equal(2, loggers.Length); Assert.Equal(fileLogger, loggers[0]); Assert.Equal(fileLogger2, loggers[1]); Assert.Equal("A", loggers[1].LogFile); }
/// <summary> /// Adds a file logger. /// </summary> /// <param name="settings">The settings.</param> /// <param name="fileLoggerParameters">Parameters to be passed to the logger.</param> /// <returns>The same <see cref="DotNetMSBuildSettings"/> instance so that multiple calls can be chained.</returns> /// <remarks> /// Each file logger will be declared in the order added. /// The first file logger will match up to the /fl parameter. /// The next nine (max) file loggers will match up to the /fl1 through /fl9 respectively. /// </remarks> public static DotNetMSBuildSettings AddFileLogger(this DotNetMSBuildSettings settings, MSBuildFileLoggerSettings fileLoggerParameters) { EnsureSettings(settings); if (fileLoggerParameters == null) { throw new ArgumentNullException(nameof(fileLoggerParameters)); } settings.FileLoggers.Add(fileLoggerParameters); return(settings); }