-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor services for testability and clean up obsolete tests #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,8 @@ Maintain the sentiment and intent of the original text. | |
| public TranslationService( | ||
| IOptions<ApiSettings> apiSettings, | ||
| TelemetryClient telemetryClient, | ||
| ILogger<TranslationService> logger) | ||
| ILogger<TranslationService> logger, | ||
| ChatClient? chatClient = null) | ||
| { | ||
| ArgumentNullException.ThrowIfNull(apiSettings); | ||
| _telemetryClient = telemetryClient; | ||
|
|
@@ -39,6 +40,12 @@ public TranslationService( | |
| var settings = apiSettings.Value; | ||
| _deploymentName = settings.AzureOpenAIDeploymentName; | ||
|
|
||
| if (chatClient != null) | ||
| { | ||
| _chatClient = chatClient; | ||
| return; | ||
| } | ||
|
|
||
| if (string.IsNullOrWhiteSpace(settings.AzureOpenAIApiKey) || | ||
| string.IsNullOrWhiteSpace(settings.AzureOpenAIEndpoint) || | ||
| string.IsNullOrWhiteSpace(settings.AzureOpenAIDeploymentName)) | ||
|
Comment on lines
41
to
51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistent Configuration Validation: Recommended solution: |
||
|
|
||
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential NullReferenceException:
The constructor does not validate
telemetryClientandloggerfor null. If either is not provided, subsequent usage will result in a runtime exception.Recommended solution:
Add explicit null checks for these dependencies: