Skip to content

Add unit coverage for Microsoft.Extensions logging builder extensions - #11100

Merged
Amaury Levé (Evangelink) merged 2 commits into
mainfrom
copilot/test-improver-add-unit-tests
Sep 8, 2026
Merged

Add unit coverage for Microsoft.Extensions logging builder extensions#11100
Amaury Levé (Evangelink) merged 2 commits into
mainfrom
copilot/test-improver-add-unit-tests

Conversation

Copilot AI commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Adds focused coverage for both AddMicrosoftExtensionsLogging overloads, covering registration behavior at the MTP logging boundary.

  • Argument validation

    • Verifies null guards for builder, logger factory, and configure delegate.
  • Disabled logging

    • Verifies LogLevel.None avoids configuring or using the MEL factory.
  • Forwarding and lifetime

    • Verifies MTP logs reach a MEL provider with category, level, and message preserved.
    • Verifies configured factories are disposed while caller-owned factories remain undisposed.
  • Fluent API

    • Verifies both overloads return the original application builder.
builder.AddMicrosoftExtensionsLogging(
    logging => logging.Services.AddSingleton<ILoggerProvider>(_ => provider));

Copilot AI balanced review requested due to automatic review settings September 8, 2026 04:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 8, 2026 05:10
Copilot AI changed the title [WIP] Add unit tests for MicrosoftExtensionsLoggingBuilderExtensions Add unit coverage for Microsoft.Extensions logging builder extensions Sep 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The tests comprehensively validate both overloads with correct assertions and resource cleanup.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@Evangelink
Amaury Levé (Evangelink) marked this pull request as ready for review September 8, 2026 06:23
@Evangelink Amaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Sep 8, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated review by GitHub Copilot. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

✅ 22/22 dimensions clean — no findings.

Notes: Single-file, test-only PR adding unit tests for MicrosoftExtensionsLoggingBuilderExtensions. Tests cover null-guard validation, configure-delegate and factory overload paths, log forwarding, disposal ownership semantics (owned vs. caller-owned factory), and LogLevel.None short-circuit behavior. Assertions use MSTest Assert (consistent with BannedSymbols.txt). Internal type casts (LoggingManager, TestApplicationBuilder) are valid via InternalsVisibleTo. Test helpers (CapturingLoggerFactory, CapturingLoggerProvider) are well-scoped as nested private classes.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

🧵 Parallel-safety audit — PR #11100

Nothing audited here touches process-global state, shared filesystem paths, or [ResourceLock] / [DoNotParallelize] declarations. Nothing to flag for parallel-safety.

The PR adds one new self-contained test class, MicrosoftExtensionsLoggingBuilderExtensionsTests.cs, to Microsoft.Testing.Extensions.UnitTests. All 9 new test methods operate purely on local in-memory objects (ITestApplicationBuilder, ILoggerFactory, custom capturing logger/provider fakes) — no Environment.*, Directory.*/File.*, Console.*, CultureInfo, or mutable static fields are touched, and no [ResourceLock] / [DoNotParallelize] declarations were added, removed, or should have been.

Audited Microsoft.Testing.Extensions.UnitTests at scope MethodLevel ([assembly: Parallelize(Scope = ExecutionScope.MethodLevel, Workers = 0)] in Program.cs), workers CPU count. No parallelization-config files were touched by this PR.

Re-run with /parallel-audit.

🤖 Automated content by GitHub Copilot. Generated by the Parallel-safety audit on PR (on open / sync) workflow. · auto · 54.9 AIC · ⌖ 4.59 AIC · ⊞ 24.9K · [◷]( · )

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

🧪 Expert test review — PR #11100

Reviewed the single new test file MicrosoftExtensionsLoggingBuilderExtensionsTests.cs (9 new [TestMethod]s covering MicrosoftExtensionsLoggingBuilderExtensions). Production code (MicrosoftExtensionsLoggingBuilderExtensions, MicrosoftExtensionsLoggingProvider, LoggingManager) was resolved from the repository. All nine tests are well-scoped, use clear AAA structure, assert concrete observable outcomes (parameter names on ArgumentNullException, forwarded category/level/message, dispose-ownership semantics, and builder chaining), and no anti-patterns (sleep, unseeded randomness, swallowed exceptions, over-mocking) were found. Every meaningful mutation on the null-guard, None-level short-circuit, and factory-ownership/dispose branches in the reviewed production paths is killed by at least one test. No high-confidence actionable findings warranted an inline suggestion.

GradeTestMutationNotesHow to improve
A (90–100) new MicrosoftExtensionsLoggingBuilderExtensionsTests.
AddMicrosoftExtensionsLogging_
ReturnsSameBuilder
2/2 killed Verifies chaining return value for both overloads with AreSame.
A (90–100) new MicrosoftExtensionsLoggingBuilderExtensionsTests.
AddMicrosoftExtensionsLogging_
WithConfigureDelegateAndNoneLevel_
DoesNotInvokeConfigureDelegate
1/1 killed Confirms the LogLevel.None short-circuit skips the configure delegate entirely.
A (90–100) new MicrosoftExtensionsLoggingBuilderExtensionsTests.
AddMicrosoftExtensionsLogging_
WithConfigureDelegate_
ForwardsLogsAndDisposesOwnedFactory
4/4 killed Asserts forwarded category/level/message and that the owned MEL factory is disposed exactly once.
A (90–100) new MicrosoftExtensionsLoggingBuilderExtensionsTests.
AddMicrosoftExtensionsLogging_
WithLoggerFactoryAndNoneLevel_
DoesNotUseFactory
2/2 killed Checks both CreateLoggerCallCount and DisposeCallCount stay zero under None.
A (90–100) new MicrosoftExtensionsLoggingBuilderExtensionsTests.
AddMicrosoftExtensionsLogging_
WithLoggerFactory_
ForwardsLogsWithoutDisposingCallerFactory
4/4 killed Confirms forwarding plus that a caller-owned factory is never disposed by the bridge.
A (90–100) new MicrosoftExtensionsLoggingBuilderExtensionsTests.
AddMicrosoftExtensionsLogging_
WithNullBuilderAndConfigureDelegate_
Throws
1/1 killed Asserts exact ParamName, not just the exception type.
A (90–100) new MicrosoftExtensionsLoggingBuilderExtensionsTests.
AddMicrosoftExtensionsLogging_
WithNullBuilderAndLoggerFactory_
Throws
1/1 killed Asserts exact ParamName for the second overload's builder guard.
A (90–100) new MicrosoftExtensionsLoggingBuilderExtensionsTests.
AddMicrosoftExtensionsLogging_
WithNullConfigureDelegate_
Throws
1/1 killed Asserts exact ParamName for the delegate guard.
A (90–100) new MicrosoftExtensionsLoggingBuilderExtensionsTests.
AddMicrosoftExtensionsLogging_
WithNullLoggerFactory_
Throws
1/1 killed Asserts exact ParamName for the logger-factory guard.

This advisory comment was generated automatically. Grades are heuristic
and informational — they do not block merging. Suggestions on the Files
changed tab can be applied with one click. Re-run with
/review-tests.

🤖 Automated content by GitHub Copilot. Generated by the Test Reviewer on PR (on open / sync) workflow. · auto · 80.5 AIC · ⌖ 2.66 AIC · ⊞ 17K · [◷]( · )

@Evangelink
Amaury Levé (Evangelink) merged commit 298480b into main Sep 8, 2026
57 of 58 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the copilot/test-improver-add-unit-tests branch September 8, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-review Awaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[test-improver] Add unit tests for MicrosoftExtensionsLoggingBuilderExtensions

4 participants