< Summary

Class:Azure.AI.TextAnalytics.AnalyzeSentimentResult
Assembly:Azure.AI.TextAnalytics
File(s):C:\Git\azure-sdk-for-net\sdk\textanalytics\Azure.AI.TextAnalytics\src\AnalyzeSentimentResult.cs
Covered lines:7
Uncovered lines:0
Coverable lines:7
Total lines:42
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_DocumentSentiment()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\textanalytics\Azure.AI.TextAnalytics\src\AnalyzeSentimentResult.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 analyze sentiment operation on a single document,
 10    /// containing the predicted sentiment for each sentence as well as for
 11    /// the full document.
 12    /// </summary>
 13    public class AnalyzeSentimentResult : TextAnalyticsResult
 14    {
 15        private readonly DocumentSentiment _documentSentiment;
 16
 17        internal AnalyzeSentimentResult(string id, TextDocumentStatistics statistics, DocumentSentiment documentSentimen
 4818            : base(id, statistics)
 19        {
 4820            _documentSentiment = documentSentiment;
 4821        }
 22
 823        internal AnalyzeSentimentResult(string id, TextAnalyticsError error) : base(id, error) { }
 24
 25        /// <summary>
 26        /// Gets the predicted sentiment for the full document.
 27        /// </summary>
 28        public DocumentSentiment DocumentSentiment
 29        {
 30            get
 31            {
 7632                if (HasError)
 33                {
 34#pragma warning disable CA1065 // Do not raise exceptions in unexpected locations
 435                    throw new InvalidOperationException($"Cannot access result for document {Id}, due to error {Error.Er
 36#pragma warning restore CA1065 // Do not raise exceptions in unexpected locations
 37                }
 7238                return _documentSentiment;
 39            }
 40        }
 41    }
 42}