Skip to content

Observer DI#34

Merged
kraldev merged 9 commits into
masterfrom
31-add-missing-http-verbs
Jan 20, 2026
Merged

Observer DI#34
kraldev merged 9 commits into
masterfrom
31-add-missing-http-verbs

Conversation

@kraldev
Copy link
Copy Markdown
Owner

@kraldev kraldev commented Jan 20, 2026

Added Observer DI support

Refactored request creation into CreateJsonRequest for consistency.
Added PostAsync, PutAsync, and DeleteAsync methods to both the client and its interface, with proper serialization and ETag handling.
Expanded XML docs for new methods.
Added unit tests for new operations, covering success and error cases.
Changed CreateJsonRequest from an instance to a static method in BusinessCentralClient, allowing it to be called without requiring an object instance. This improves clarity and usage for methods that do not depend on instance state.
Updated the project version in Dynamics365.BusinessCentral.csproj from 0.1.10 to 1.0.0-alpha, marking the transition to a new major version and indicating an alpha release. No other changes were made.
Refactor BusinessCentralOptions registration to use a singleton instance instead of IOptions. Update BusinessCentralClient registration to use a factory, allowing injection of an optional IBusinessCentralObserver. Add AddBusinessCentralObserver<TObserver> extension method for registering custom observer implementations. These changes improve flexibility and diagnostics extensibility.
Renamed AddBusinessCentralObserver<T> to AddObserver<T> for clarity and removed its XML doc comment. Moved test utility classes to a new Utils namespace to better separate test helpers from test cases. Updated usings accordingly. Added ServiceCollectionExtensionsTests to verify DI registration of the client and observer. Made minor comment and formatting improvements in ServiceCollectionExtensions.
Added a using directive for Dynamics365.BusinessCentral.Tests.Utils to ClientTests.cs to enable access to utility classes and methods from the Tests.Utils namespace. No other changes were made.
Added BusinessCentralClient_Factory_Executes_Without_Observer unit test to ensure IBusinessCentralClient can be resolved from the service provider when registered without an observer. The test verifies correct registration and configuration.
Refactored ServiceCollectionExtensionsTests for improved clarity and coverage. Centralized default options setup, renamed and reorganized tests for better intent, added new tests for observer and options registration, and removed obsolete tests. Simplified TestObserver and cleaned up usings. Tests are now more focused, DRY, and provide better verification of DI service and options registration.
Annotated ServiceCollectionExtensions with [ExcludeFromCodeCoverage] to exclude it from code coverage analysis. Imported System.Diagnostics.CodeAnalysis to support this attribute. No functional changes were made.
@sonarqubecloud
Copy link
Copy Markdown

@kraldev kraldev merged commit eca1267 into master Jan 20, 2026
2 checks passed
@kraldev kraldev deleted the 31-add-missing-http-verbs branch January 20, 2026 16:06
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