-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shorten code required to instrument options (#15698)
Fixes: #15692
- Loading branch information
1 parent
315b1df
commit 88f5130
Showing
37 changed files
with
150 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...malydetector/Azure.AI.AnomalyDetector/tests/Infrastructure/AnomalyDetectorLiveTestBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using Azure.Core; | ||
using Azure.Core.TestFramework; | ||
|
||
namespace Azure.AI.AnomalyDetector.Tests | ||
{ | ||
public class AnomalyDetectorLiveTestBase : RecordedTestBase<AnomalyDetectorTestEnvironment> | ||
{ | ||
public AnomalyDetectorLiveTestBase(bool isAsync) : base(isAsync) | ||
{ | ||
Sanitizer = new AnomalyDetectorRecordedTestSanitizer(); | ||
} | ||
|
||
/// <summary> | ||
/// Creates a <see cref="AnomalyDetectorClient" /> with the endpoint and API key provided via environment | ||
/// variables and instruments it to make use of the Azure Core Test Framework functionalities. | ||
/// </summary> | ||
/// <param name="useTokenCredential">Whether or not to use a <see cref="TokenCredential"/> to authenticate. An <see cref="AzureKeyCredential"/> is used by default.</param> | ||
/// <param name="apiKey">The API key to use for authentication. Defaults to <see cref="AnomalyDetectorTestEnvironment.ApiKey"/>.</param> | ||
/// <param name="skipInstrumenting">Whether or not instrumenting should be skipped. Avoid skipping it as much as possible.</param> | ||
/// <returns>The instrumented <see cref="AnomalyDetectorClient" />.</returns> | ||
protected AnomalyDetectorClient CreateAnomalyDetectorClient(bool useTokenCredential = false, string apiKey = default, bool skipInstrumenting = false) | ||
{ | ||
var endpoint = new Uri(TestEnvironment.Endpoint); | ||
var options = InstrumentClientOptions(new AnomalyDetectorClientOptions()); | ||
AnomalyDetectorClient client; | ||
|
||
if (useTokenCredential) | ||
{ | ||
client = new AnomalyDetectorClient(endpoint, TestEnvironment.Credential, options); | ||
} | ||
else | ||
{ | ||
var credential = new AzureKeyCredential(apiKey ?? TestEnvironment.ApiKey); | ||
client = new AnomalyDetectorClient(endpoint, credential, options); | ||
} | ||
|
||
return skipInstrumenting ? client : InstrumentClient(client); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.