diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/CHANGELOG.md b/sdk/textanalytics/Azure.AI.TextAnalytics/CHANGELOG.md index 9b965ae030dc..c38be376c79b 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/CHANGELOG.md +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/CHANGELOG.md @@ -5,7 +5,8 @@ - Added support for service version `3.0`. This can be specified in the `TextAnalyticsClientOptions` object under the `ServiceVersion` enum. By default the SDK targets latest supported service version. - Added value `None` to enum `PiiEntityDomainType` to allow user to specify no domain. - Added property `ActionName` to all `xxActions` input types so user can specify a name per action. If not provided, service will generate a name. -- Added property `ActionName` to all `xxActionResult` output types that displays the name of each action. +- Added property `ActionName` to all `xxActionResult` output types that displays the name of each action. +- Added new overload methods to all `xxActions` types that take a `xxOptions` object to facilitate a transition from a singular method to an actions method. - The parameter `CategoriesFilter` in `RecognizePiiEntitiesActions` has been enabled for `StartAnalyzeActions` methods. ### Breaking changes diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/api/Azure.AI.TextAnalytics.netstandard2.0.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/api/Azure.AI.TextAnalytics.netstandard2.0.cs index e1787087602c..d861737dba81 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/api/Azure.AI.TextAnalytics.netstandard2.0.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/api/Azure.AI.TextAnalytics.netstandard2.0.cs @@ -83,6 +83,7 @@ internal AnalyzeHealthcareEntitiesResultCollection() : base (default(System.Coll public partial class AnalyzeSentimentAction { public AnalyzeSentimentAction() { } + public AnalyzeSentimentAction(Azure.AI.TextAnalytics.AnalyzeSentimentOptions options) { } public string ActionName { get { throw null; } set { } } public bool? DisableServiceLogs { get { throw null; } set { } } public bool? IncludeOpinionMining { get { throw null; } set { } } @@ -231,6 +232,7 @@ internal EntityDataSource() { } public partial class ExtractKeyPhrasesAction { public ExtractKeyPhrasesAction() { } + public ExtractKeyPhrasesAction(Azure.AI.TextAnalytics.TextAnalyticsRequestOptions options) { } public string ActionName { get { throw null; } set { } } public bool? DisableServiceLogs { get { throw null; } set { } } public string ModelVersion { get { throw null; } set { } } @@ -612,6 +614,7 @@ public enum PiiEntityDomain public partial class RecognizeEntitiesAction { public RecognizeEntitiesAction() { } + public RecognizeEntitiesAction(Azure.AI.TextAnalytics.TextAnalyticsRequestOptions options) { } public string ActionName { get { throw null; } set { } } public bool? DisableServiceLogs { get { throw null; } set { } } public string ModelVersion { get { throw null; } set { } } @@ -636,6 +639,7 @@ internal RecognizeEntitiesResultCollection() : base (default(System.Collections. public partial class RecognizeLinkedEntitiesAction { public RecognizeLinkedEntitiesAction() { } + public RecognizeLinkedEntitiesAction(Azure.AI.TextAnalytics.TextAnalyticsRequestOptions options) { } public string ActionName { get { throw null; } set { } } public bool? DisableServiceLogs { get { throw null; } set { } } public string ModelVersion { get { throw null; } set { } } @@ -660,6 +664,7 @@ internal RecognizeLinkedEntitiesResultCollection() : base (default(System.Collec public partial class RecognizePiiEntitiesAction { public RecognizePiiEntitiesAction() { } + public RecognizePiiEntitiesAction(Azure.AI.TextAnalytics.RecognizePiiEntitiesOptions options) { } public string ActionName { get { throw null; } set { } } public System.Collections.Generic.IList CategoriesFilter { get { throw null; } } public bool? DisableServiceLogs { get { throw null; } set { } } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeSentimentAction.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeSentimentAction.cs index a34fb88bb47c..bdc31f936f6e 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeSentimentAction.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/AnalyzeSentimentAction.cs @@ -20,6 +20,19 @@ public AnalyzeSentimentAction() { } + /// + /// Initializes a new instance of the + /// class based on the values of a . + /// It sets the , the , + /// and the properties. + /// + public AnalyzeSentimentAction(AnalyzeSentimentOptions options) + { + ModelVersion = options.ModelVersion; + DisableServiceLogs = options.DisableServiceLogs; + IncludeOpinionMining = options.IncludeOpinionMining; + } + /// /// Gets or sets a value that, if set, indicates the version of the text /// analytics model that will be used to generate the result. For supported diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/ExtractKeyPhrasesAction.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/ExtractKeyPhrasesAction.cs index 338afdf31647..ca0f2d6fc3ce 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/ExtractKeyPhrasesAction.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/ExtractKeyPhrasesAction.cs @@ -20,6 +20,17 @@ public ExtractKeyPhrasesAction() { } + /// + /// Initializes a new instance of the + /// class based on the values of a . + /// It sets the and properties. + /// + public ExtractKeyPhrasesAction(TextAnalyticsRequestOptions options) + { + ModelVersion = options.ModelVersion; + DisableServiceLogs = options.DisableServiceLogs; + } + /// /// Gets or sets a value that, if set, indicates the version of the text /// analytics model that will be used to generate the result. For supported diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizeEntitiesAction.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizeEntitiesAction.cs index f4f35ecb5ff6..a1ba8504cecd 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizeEntitiesAction.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizeEntitiesAction.cs @@ -20,6 +20,17 @@ public RecognizeEntitiesAction() { } + /// + /// Initializes a new instance of the + /// class based on the values of a . + /// It sets the and properties. + /// + public RecognizeEntitiesAction(TextAnalyticsRequestOptions options) + { + ModelVersion = options.ModelVersion; + DisableServiceLogs = options.DisableServiceLogs; + } + /// /// Gets or sets a value that, if set, indicates the version of the text /// analytics model that will be used to generate the result. For supported diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizeLinkedEntitiesAction.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizeLinkedEntitiesAction.cs index d57a731ba511..2c8829aead95 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizeLinkedEntitiesAction.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizeLinkedEntitiesAction.cs @@ -20,6 +20,17 @@ public RecognizeLinkedEntitiesAction() { } + /// + /// Initializes a new instance of the + /// class based on the values of a . + /// It sets the and properties. + /// + public RecognizeLinkedEntitiesAction(TextAnalyticsRequestOptions options) + { + ModelVersion = options.ModelVersion; + DisableServiceLogs = options.DisableServiceLogs; + } + /// /// Gets or sets a value that, if set, indicates the version of the text /// analytics model that will be used to generate the result. For supported diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizePiiEntitiesAction.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizePiiEntitiesAction.cs index 1bf636a7a5e3..3b683785c06e 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizePiiEntitiesAction.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/RecognizePiiEntitiesAction.cs @@ -24,6 +24,23 @@ public RecognizePiiEntitiesAction() { } + /// + /// Initializes a new instance of the + /// class based on the values of a . + /// It sets the , , + /// , and properties. + /// + public RecognizePiiEntitiesAction(RecognizePiiEntitiesOptions options) + { + ModelVersion = options.ModelVersion; + DisableServiceLogs = options.DisableServiceLogs; + DomainFilter = options.DomainFilter; + if (options.CategoriesFilter.Count > 0) + { + CategoriesFilter = new List(options.CategoriesFilter); + } + } + /// /// Gets or sets a value that, if set, indicates the version of the text /// analytics model that will be used to generate the result. For supported diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Transforms.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Transforms.cs index dbda53a48b4f..29701878ae8c 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/src/Transforms.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/src/Transforms.cs @@ -322,16 +322,22 @@ private static int ParseHealthcareEntityIndex(string reference) internal static PiiTask ConvertToPiiTask(RecognizePiiEntitiesAction action) { + var parameters = new PiiTaskParameters() + { + Domain = action.DomainFilter.GetString() ?? (PiiTaskParametersDomain?)null, + ModelVersion = action.ModelVersion, + StringIndexType = Constants.DefaultStringIndexType, + LoggingOptOut = action.DisableServiceLogs + }; + + if (action.CategoriesFilter.Count > 0) + { + parameters.PiiCategories = action.CategoriesFilter; + } + return new PiiTask() { - Parameters = new PiiTaskParameters() - { - Domain = action.DomainFilter.GetString() ?? (PiiTaskParametersDomain?)null, - ModelVersion = action.ModelVersion, - StringIndexType = Constants.DefaultStringIndexType, - LoggingOptOut = action.DisableServiceLogs, - PiiCategories = action.CategoriesFilter - }, + Parameters = parameters, TaskName = action.ActionName }; } diff --git a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/AnalyzeOperationMockTests.cs b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/AnalyzeOperationMockTests.cs index 4330cd618020..ec52363467cc 100644 --- a/sdk/textanalytics/Azure.AI.TextAnalytics/tests/AnalyzeOperationMockTests.cs +++ b/sdk/textanalytics/Azure.AI.TextAnalytics/tests/AnalyzeOperationMockTests.cs @@ -36,6 +36,8 @@ private TextAnalyticsClient CreateTestClient(HttpPipelineTransport transport) return client; } + #region Key phrases + [Test] public async Task AnalyzeOperationKeyPhrasesWithDisableServiceLogs() { @@ -69,6 +71,73 @@ public async Task AnalyzeOperationKeyPhrasesWithDisableServiceLogs() Assert.AreEqual(expectedContent, logging); } + [Test] + public async Task AnalyzeOperationKeyPhrasesFromRequestOptions() + { + var mockResponse = new MockResponse(202); + mockResponse.AddHeader(new HttpHeader("Operation-Location", "something/jobs/2a96a91f-7edf-4931-a880-3fdee1d56f15")); + + var mockTransport = new MockTransport(new[] { mockResponse, mockResponse }); + var client = CreateTestClient(mockTransport); + + var documents = new List + { + "Elon Musk is the CEO of SpaceX and Tesla." + }; + + var options = new TextAnalyticsRequestOptions(); + + var actions = new ExtractKeyPhrasesAction(options); + + TextAnalyticsActions batchActions = new() + { + ExtractKeyPhrasesActions = new List() { actions }, + }; + + await client.StartAnalyzeActionsAsync(documents, batchActions); + + var contentString = GetString(mockTransport.Requests.Single().Content); + ValidateRequestOptions(contentString); + } + + [Test] + public async Task AnalyzeOperationKeyPhrasesFromRequestOptionsFull() + { + var mockResponse = new MockResponse(202); + mockResponse.AddHeader(new HttpHeader("Operation-Location", "something/jobs/2a96a91f-7edf-4931-a880-3fdee1d56f15")); + + var mockTransport = new MockTransport(new[] { mockResponse, mockResponse }); + var client = CreateTestClient(mockTransport); + + var documents = new List + { + "Elon Musk is the CEO of SpaceX and Tesla." + }; + + var options = new TextAnalyticsRequestOptions() + { + ModelVersion = "latest", + DisableServiceLogs = true, + IncludeStatistics = false + }; + + var actions = new ExtractKeyPhrasesAction(options); + + TextAnalyticsActions batchActions = new() + { + ExtractKeyPhrasesActions = new List() { actions }, + }; + + await client.StartAnalyzeActionsAsync(documents, batchActions); + + var contentString = GetString(mockTransport.Requests.Single().Content); + ValidateRequestOptions(contentString, true); + } + + #endregion Key phrases + + #region entities + [Test] public async Task AnalyzeOperationRecognizeEntitiesWithDisableServiceLogs() { @@ -102,6 +171,73 @@ public async Task AnalyzeOperationRecognizeEntitiesWithDisableServiceLogs() Assert.AreEqual(expectedContent, logging); } + [Test] + public async Task AnalyzeOperationRecognizeEntitiesWithRequestOptions() + { + var mockResponse = new MockResponse(202); + mockResponse.AddHeader(new HttpHeader("Operation-Location", "something/jobs/2a96a91f-7edf-4931-a880-3fdee1d56f15")); + + var mockTransport = new MockTransport(new[] { mockResponse, mockResponse }); + var client = CreateTestClient(mockTransport); + + var documents = new List + { + "Elon Musk is the CEO of SpaceX and Tesla." + }; + + var options = new TextAnalyticsRequestOptions(); + + var actions = new RecognizeEntitiesAction(options); + + TextAnalyticsActions batchActions = new TextAnalyticsActions() + { + RecognizeEntitiesActions = new List() { actions }, + }; + + await client.StartAnalyzeActionsAsync(documents, batchActions); + + var contentString = GetString(mockTransport.Requests.Single().Content); + ValidateRequestOptions(contentString); + } + + [Test] + public async Task AnalyzeOperationRecognizeEntitiesWithRequestOptionsFull() + { + var mockResponse = new MockResponse(202); + mockResponse.AddHeader(new HttpHeader("Operation-Location", "something/jobs/2a96a91f-7edf-4931-a880-3fdee1d56f15")); + + var mockTransport = new MockTransport(new[] { mockResponse, mockResponse }); + var client = CreateTestClient(mockTransport); + + var documents = new List + { + "Elon Musk is the CEO of SpaceX and Tesla." + }; + + var options = new TextAnalyticsRequestOptions() + { + ModelVersion = "latest", + DisableServiceLogs = true, + IncludeStatistics = false + }; + + var actions = new RecognizeEntitiesAction(options); + + TextAnalyticsActions batchActions = new TextAnalyticsActions() + { + RecognizeEntitiesActions = new List() { actions }, + }; + + await client.StartAnalyzeActionsAsync(documents, batchActions); + + var contentString = GetString(mockTransport.Requests.Single().Content); + ValidateRequestOptions(contentString, true); + } + + #endregion entities + + #region linked entities + [Test] public async Task AnalyzeOperationRecognizeLinkedEntitiesWithDisableServiceLogs() { @@ -135,6 +271,73 @@ public async Task AnalyzeOperationRecognizeLinkedEntitiesWithDisableServiceLogs( Assert.AreEqual(expectedContent, logging); } + [Test] + public async Task AnalyzeOperationRecognizeLinkedEntitiesWithRequestOptions() + { + var mockResponse = new MockResponse(202); + mockResponse.AddHeader(new HttpHeader("Operation-Location", "something/jobs/2a96a91f-7edf-4931-a880-3fdee1d56f15")); + + var mockTransport = new MockTransport(new[] { mockResponse, mockResponse }); + var client = CreateTestClient(mockTransport); + + var documents = new List + { + "Elon Musk is the CEO of SpaceX and Tesla." + }; + + var options = new TextAnalyticsRequestOptions(); + + var actions = new RecognizeLinkedEntitiesAction(options); + + TextAnalyticsActions batchActions = new TextAnalyticsActions() + { + RecognizeLinkedEntitiesActions = new List() { actions }, + }; + + await client.StartAnalyzeActionsAsync(documents, batchActions); + + var contentString = GetString(mockTransport.Requests.Single().Content); + ValidateRequestOptions(contentString); + } + + [Test] + public async Task AnalyzeOperationRecognizeLinkedEntitiesWithRequestOptionsFull() + { + var mockResponse = new MockResponse(202); + mockResponse.AddHeader(new HttpHeader("Operation-Location", "something/jobs/2a96a91f-7edf-4931-a880-3fdee1d56f15")); + + var mockTransport = new MockTransport(new[] { mockResponse, mockResponse }); + var client = CreateTestClient(mockTransport); + + var documents = new List + { + "Elon Musk is the CEO of SpaceX and Tesla." + }; + + var options = new TextAnalyticsRequestOptions() + { + ModelVersion = "latest", + DisableServiceLogs = true, + IncludeStatistics = false + }; + + var actions = new RecognizeLinkedEntitiesAction(options); + + TextAnalyticsActions batchActions = new TextAnalyticsActions() + { + RecognizeLinkedEntitiesActions = new List() { actions }, + }; + + await client.StartAnalyzeActionsAsync(documents, batchActions); + + var contentString = GetString(mockTransport.Requests.Single().Content); + ValidateRequestOptions(contentString, true); + } + + #endregion linked entities + + #region Pii entities + [Test] public async Task AnalyzeOperationRecognizePiiEntitiesWithDisableServiceLogs() { @@ -168,6 +371,192 @@ public async Task AnalyzeOperationRecognizePiiEntitiesWithDisableServiceLogs() Assert.AreEqual(expectedContent, logging); } + [Test] + public async Task AnalyzeOperationRecognizePiiEntitiesWithPiiOptions() + { + var mockResponse = new MockResponse(202); + mockResponse.AddHeader(new HttpHeader("Operation-Location", "something/jobs/2a96a91f-7edf-4931-a880-3fdee1d56f15")); + + var mockTransport = new MockTransport(new[] { mockResponse, mockResponse }); + var client = CreateTestClient(mockTransport); + + var documents = new List + { + "Elon Musk is the CEO of SpaceX and Tesla." + }; + + var options = new RecognizePiiEntitiesOptions(); + + var actions = new RecognizePiiEntitiesAction(options); + + TextAnalyticsActions batchActions = new TextAnalyticsActions() + { + RecognizePiiEntitiesActions = new List() { actions }, + }; + + await client.StartAnalyzeActionsAsync(documents, batchActions); + + var contentString = GetString(mockTransport.Requests.Single().Content); + ValidateRequestOptions(contentString); + Assert.AreEqual(-1, contentString.IndexOf("domain")); + Assert.AreEqual(-1, contentString.IndexOf("piiCategories")); + } + + [Test] + public async Task AnalyzeOperationRecognizePiiEntitiesWithPiiOptionsFull() + { + var mockResponse = new MockResponse(202); + mockResponse.AddHeader(new HttpHeader("Operation-Location", "something/jobs/2a96a91f-7edf-4931-a880-3fdee1d56f15")); + + var mockTransport = new MockTransport(new[] { mockResponse, mockResponse }); + var client = CreateTestClient(mockTransport); + + var documents = new List + { + "Elon Musk is the CEO of SpaceX and Tesla." + }; + + var options = new RecognizePiiEntitiesOptions() + { + ModelVersion = "latest", + DisableServiceLogs = true, + IncludeStatistics = true, + DomainFilter = PiiEntityDomain.ProtectedHealthInformation, + CategoriesFilter = { PiiEntityCategory.USSocialSecurityNumber } + }; + + var actions = new RecognizePiiEntitiesAction(options); + + TextAnalyticsActions batchActions = new TextAnalyticsActions() + { + RecognizePiiEntitiesActions = new List() { actions }, + }; + + await client.StartAnalyzeActionsAsync(documents, batchActions); + + var contentString = GetString(mockTransport.Requests.Single().Content); + ValidateRequestOptions(contentString, true); + + string domaintFilter = contentString.Substring(contentString.IndexOf("domain"), 13); + + var expectedDomainFilterContent = "domain\":\"phi\""; + Assert.AreEqual(expectedDomainFilterContent, domaintFilter); + + string piiCategories = contentString.Substring(contentString.IndexOf("piiCategories"), 41); + + var expectedPiiCategoriesContent = "piiCategories\":[\"USSocialSecurityNumber\"]"; + Assert.AreEqual(expectedPiiCategoriesContent, piiCategories); + } + + #endregion Pii entities + + #region Analyze sentiment + + [Test] + public async Task AnalyzeOperationAnalyzeSentimentWithDisableServiceLogs() + { + var mockResponse = new MockResponse(202); + mockResponse.AddHeader(new HttpHeader("Operation-Location", "something/jobs/2a96a91f-7edf-4931-a880-3fdee1d56f15")); + + var mockTransport = new MockTransport(new[] { mockResponse, mockResponse }); + var client = CreateTestClient(mockTransport); + + var documents = new List + { + "Elon Musk is the CEO of SpaceX and Tesla." + }; + + var actions = new AnalyzeSentimentAction() + { + DisableServiceLogs = true + }; + + TextAnalyticsActions batchActions = new TextAnalyticsActions() + { + AnalyzeSentimentActions = new List() { actions }, + }; + + await client.StartAnalyzeActionsAsync(documents, batchActions); + + var contentString = GetString(mockTransport.Requests.Single().Content); + string logging = contentString.Substring(contentString.IndexOf("loggingOptOut"), 19); + + var expectedContent = "loggingOptOut\":true"; + Assert.AreEqual(expectedContent, logging); + } + + [Test] + public async Task AnalyzeOperationAnalyzeSentimentWithAnalyzeSentimentOptions() + { + var mockResponse = new MockResponse(202); + mockResponse.AddHeader(new HttpHeader("Operation-Location", "something/jobs/2a96a91f-7edf-4931-a880-3fdee1d56f15")); + + var mockTransport = new MockTransport(new[] { mockResponse, mockResponse }); + var client = CreateTestClient(mockTransport); + + var documents = new List + { + "Elon Musk is the CEO of SpaceX and Tesla." + }; + + var options = new AnalyzeSentimentOptions(); + + var actions = new AnalyzeSentimentAction(options); + + TextAnalyticsActions batchActions = new TextAnalyticsActions() + { + AnalyzeSentimentActions = new List() { actions }, + }; + + await client.StartAnalyzeActionsAsync(documents, batchActions); + + var contentString = GetString(mockTransport.Requests.Single().Content); + ValidateRequestOptions(contentString); + Assert.AreEqual(-1, contentString.IndexOf("opinionMining")); + } + + [Test] + public async Task AnalyzeOperationAnalyzeSentimentWithAnalyzeSentimentOptionsFull() + { + var mockResponse = new MockResponse(202); + mockResponse.AddHeader(new HttpHeader("Operation-Location", "something/jobs/2a96a91f-7edf-4931-a880-3fdee1d56f15")); + + var mockTransport = new MockTransport(new[] { mockResponse, mockResponse }); + var client = CreateTestClient(mockTransport); + + var documents = new List + { + "Elon Musk is the CEO of SpaceX and Tesla." + }; + + var options = new AnalyzeSentimentOptions() + { + ModelVersion = "latest", + DisableServiceLogs = true, + IncludeStatistics = true, + IncludeOpinionMining = true + }; + + var actions = new AnalyzeSentimentAction(options); + + TextAnalyticsActions batchActions = new TextAnalyticsActions() + { + AnalyzeSentimentActions = new List() { actions }, + }; + + await client.StartAnalyzeActionsAsync(documents, batchActions); + + var contentString = GetString(mockTransport.Requests.Single().Content); + ValidateRequestOptions(contentString, true); + + string opinionMining = contentString.Substring(contentString.IndexOf("opinionMining"), 19); + + var expectedOpinionMiningContent = "opinionMining\":true"; + Assert.AreEqual(expectedOpinionMiningContent, opinionMining); + } + + #endregion Analyze sentiment + [Test] public async Task AnalyzeOperationWithActionsError() { @@ -314,5 +703,29 @@ private static string GetString(RequestContent content) return Encoding.UTF8.GetString(stream.ToArray()); } + + private static void ValidateRequestOptions(string contentString, bool full = false) + { + if (!full) + { + Assert.AreEqual(-1, contentString.IndexOf("loggingOptOut")); + Assert.AreEqual(-1, contentString.IndexOf("model-version")); + Assert.AreEqual(-1, contentString.IndexOf("show-stats")); + } + else + { + string logging = contentString.Substring(contentString.IndexOf("loggingOptOut"), 19); + + var expectedContent = "loggingOptOut\":true"; + Assert.AreEqual(expectedContent, logging); + + string modelVersion = contentString.Substring(contentString.IndexOf("model-version"), 23); + + var expectedModelVersionContent = "model-version\":\"latest\""; + Assert.AreEqual(expectedModelVersionContent, modelVersion); + + Assert.AreEqual(-1, contentString.IndexOf("show-stats")); + } + } } }