< Summary

Class:Azure.AI.TextAnalytics.DetectLanguageResult
Assembly:Azure.AI.TextAnalytics
File(s):C:\Git\azure-sdk-for-net\sdk\textanalytics\Azure.AI.TextAnalytics\src\DetectLanguageResult.cs
Covered lines:7
Uncovered lines:0
Coverable lines:7
Total lines:41
Line coverage:100% (7 of 7)
Covered branches:2
Total branches:2
Branch coverage:100% (2 of 2)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
.ctor(...)-100%100%
get_PrimaryLanguage()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\textanalytics\Azure.AI.TextAnalytics\src\DetectLanguageResult.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5
 6namespace Azure.AI.TextAnalytics
 7{
 8    /// <summary>
 9    /// The result of the detect language operation on a single document,
 10    /// containing a prediction of what language the document is written in.
 11    /// </summary>
 12    public class DetectLanguageResult : TextAnalyticsResult
 13    {
 14        private readonly DetectedLanguage _primaryLanguage;
 15
 16        internal DetectLanguageResult(string id, TextDocumentStatistics statistics, DetectedLanguage detectedLanguage)
 6017            : base(id, statistics)
 18        {
 6019            _primaryLanguage = detectedLanguage;
 6020        }
 21
 822        internal DetectLanguageResult(string id, TextAnalyticsError error) : base(id, error) { }
 23
 24        /// <summary>
 25        /// The primary language detected in the document.
 26        /// </summary>
 27        public DetectedLanguage PrimaryLanguage
 28        {
 29            get
 30            {
 5631                if (HasError)
 32                {
 33#pragma warning disable CA1065 // Do not raise exceptions in unexpected locations
 434                    throw new InvalidOperationException($"Cannot access result for document {Id}, due to error {Error.Er
 35#pragma warning restore CA1065 // Do not raise exceptions in unexpected locations
 36                }
 5237                return _primaryLanguage;
 38            }
 39        }
 40    }
 41}