Skip to content

Update/20260606 tests mocks - #26

Merged
bitai-cs merged 5 commits into
mainfrom
update/20260606-tests-mocks
Jun 7, 2026
Merged

Update/20260606 tests mocks#26
bitai-cs merged 5 commits into
mainfrom
update/20260606-tests-mocks

Conversation

@bitai-cs

@bitai-cs bitai-cs commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Decoupled data-persistent ldap mocks.

Summary by Sourcery

Extract LDAP adapter contracts into a dedicated abstraction project and update mocks and demo code to use adapter interfaces and a persistent in-memory LDAP data store for testing and demo scenarios.

New Features:

  • Introduce a Bitai.LDAPHelper.LdapAdapters project that defines LDAP connection, search, entry, attribute, and modification interfaces plus supporting enums.
  • Add a Bitai.LDAPHelper.Tests.Mocks project readme and documentation describing in-memory LDAP mock usage and seeded directory behavior.

Enhancements:

  • Refactor ConnectionInfo and SearchLimits to implement new adapter interfaces for decoupling core LDAP helper logic from concrete adapter implementations.
  • Move and rename demo mock LDAP data seeder and store into the tests mocks project, adding logging, print helpers, and seeding of additional demo users.
  • Adjust mock and Novell LDAP adapter implementations and factories to depend on IConnectionInfo and ISearchLimits instead of concrete types, and align the demo to use the persistent mock LDAP implementation.

Documentation:

  • Add README files for the LdapAdapters abstraction package and the Tests.Mocks in-memory LDAP mocks package, including usage examples and project metadata.

Tests:

  • Enhance the tests mocks infrastructure with a shared in-memory LDAP data store and data seeder used by tests and the demo application.

@sourcery-ai

sourcery-ai Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Decouples LDAP mocks and mock data seeding from the demo project into a reusable test-mocks package and formalizes adapter interfaces for connection and search limits, updating all adapters and demo wiring accordingly.

File-Level Changes

Change Details Files
Move mock LDAP data store and persistent mock connection from demo into a dedicated tests mocks project and update demo to consume it.
  • Rename and move MockDataSeeder to MockLdapDataSeeder under tests mocks namespace and switch from Serilog static logging to ILogger injection, adding a PrintAllData helper.
  • Rename and move MockDataStore to MockLdapDataStore singleton under tests mocks namespace and update all references.
  • Rename and move PersistentMockLdapConnectionAdapter and its factory to MockLdapPersistenConnectionAdapter and MockLdapPersistentConnectionFactoryAdapter in tests mocks.
  • Update Program.cs mock-implementation branch to use the new tests mocks adapters and seeder, wiring up an ILogger via LoggerFactory and printing all seeded entries.
demo/Bitai.LDAPHelper.Demo/Program.cs
demo/Bitai.LDAPHelper.Demo/Mocks/LdapData/MockDataSeeder.cs
demo/Bitai.LDAPHelper.Demo/Mocks/LdapData/MockDataStore.cs
demo/Bitai.LDAPHelper.Demo/Mocks/LdapAdapters/PersistentMockLdapConnectionAdapter.cs
demo/Bitai.LDAPHelper.Demo/Mocks/LdapAdapters/PersistentMockLdapConnectionFactoryAdapter.cs
tests/Bitai.LDAPHelper.Tests.Mocks/LdapData/MockLdapDataSeeder.cs
tests/Bitai.LDAPHelper.Tests.Mocks/LdapData/MockLdapDataStore.cs
tests/Bitai.LDAPHelper.Tests.Mocks/LdapAdapters/MockLdapPersistenConnectionAdapter.cs
tests/Bitai.LDAPHelper.Tests.Mocks/LdapAdapters/MockLdapPersistentConnectionFactoryAdapter.cs
Introduce adapter-level abstractions for connection info and search limits and update all LDAP adapters and mocks to consume the interfaces.
  • Make ConnectionInfo implement new IConnectionInfo interface and keep existing properties immutable.
  • Make SearchLimits implement new ISearchLimits interface from adapters and preserve existing semantics.
  • Change ILdapConnectionFactoryAdapter and its implementations (Novell and mocks) to use IConnectionInfo instead of concrete ConnectionInfo.
  • Change ILdapConnectionAdapter and all implementations (Novell and mocks) to use ISearchLimits in SearchAsync signatures.
  • Move LdapModificationType and LdapSearchScope enums out of Bitai.LDAPHelper.Enums into Bitai.LDAPHelper.LdapAdapters and update using sites implicitly via shared namespace.
src/Bitai.LDAPHelper/ConnectionInfo.cs
src/Bitai.LDAPHelper/SearchLimits.cs
src/Bitai.LDAPHelper/Enums.cs
src/Bitai.LDAPHelper/LdapAdapters/ILdapConnectionFactoryAdapter.cs
src/Bitai.LDAPHelper/LdapAdapters/ILdapConnectionAdapter.cs
src/Bitai.LDAPHelper/LdapAdapters/Novell/NovellLdapConnectionAdapter.cs
src/Bitai.LDAPHelper/LdapAdapters/Novell/NovellLdapConnectionFactoryAdapter.cs
tests/Bitai.LDAPHelper.Tests.Mocks/LdapAdapters/MockLdapConnectionAdapter.cs
tests/Bitai.LDAPHelper.Tests.Mocks/LdapAdapters/MockLdapConnectionFactoryAdapter.cs
Create a standalone Bitai.LDAPHelper.LdapAdapters project with its own contracts, enums, license, and documentation, and document the tests mocks project.
  • Add new Bitai.LDAPHelper.LdapAdapters project with IConnectionInfo, ISearchLimits, LdapModificationType, LdapSearchScope and a dedicated csproj.
  • Add README and MIT LICENSE documents for both the LdapAdapters and Tests.Mocks projects describing purpose, usage, and metadata.
  • Update solution and project references (demo, core library, tests mocks) to include the new adapters project and organize dependencies.
src/Bitai.LDAPHelper.LdapAdapters/Bitai.LDAPHelper.LdapAdapters.csproj
src/Bitai.LDAPHelper.LdapAdapters/README.md
src/Bitai.LDAPHelper.LdapAdapters/LICENSE.md
src/Bitai.LDAPHelper.LdapAdapters/Enums.cs
src/Bitai.LDAPHelper.LdapAdapters/IConnectionInfo.cs
src/Bitai.LDAPHelper.LdapAdapters/ISearchLimits.cs
tests/Bitai.LDAPHelper.Tests.Mocks/README.md
tests/Bitai.LDAPHelper.Tests.Mocks/LICENSE.md
Bitai.Ldap.Helper.sln
demo/Bitai.LDAPHelper.Demo/Bitai.LDAPHelper.Demo.csproj
src/Bitai.LDAPHelper/Bitai.LDAPHelper.csproj
tests/Bitai.LDAPHelper.Tests.Mocks/Bitai.LDAPHelper.Tests.Mocks.csproj

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai 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.

Hey - I've left some high level feedback:

  • The new persistent mock connection type is named MockLdapPersistenConnectionAdapter (missing the trailing 't'); consider renaming it (and the file) to MockLdapPersistentConnectionAdapter for consistency and easier discoverability alongside MockLdapPersistentConnectionFactoryAdapter.
  • In MockLdapPersistentConnectionFactoryAdapter.CreateConnectionAsync you call _connection.BindAsync(userAccount, password) without awaiting it; if bind failures should be observable to callers, consider awaiting this task (and propagating exceptions) before returning the connection.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new persistent mock connection type is named `MockLdapPersistenConnectionAdapter` (missing the trailing 't'); consider renaming it (and the file) to `MockLdapPersistentConnectionAdapter` for consistency and easier discoverability alongside `MockLdapPersistentConnectionFactoryAdapter`.
- In `MockLdapPersistentConnectionFactoryAdapter.CreateConnectionAsync` you call `_connection.BindAsync(userAccount, password)` without awaiting it; if bind failures should be observable to callers, consider awaiting this task (and propagating exceptions) before returning the connection.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@bitai-cs
bitai-cs merged commit d9df52f into main Jun 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant