< Summary

Class:Microsoft.Azure.CognitiveServices.Vision.Face.EmotionExtensions
Assembly:Microsoft.Azure.CognitiveServices.Vision.Face
File(s):C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Vision.Face\src\Customizations\EmotionExtensions.cs
Covered lines:13
Uncovered lines:0
Coverable lines:13
Total lines:33
Line coverage:100% (13 of 13)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
ToRankedList(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Vision.Face\src\Customizations\EmotionExtensions.cs

#LineLine coverage
 1using System.Collections.Generic;
 2using System.Linq;
 3using Microsoft.Azure.CognitiveServices.Vision.Face.Models;
 4
 5namespace Microsoft.Azure.CognitiveServices.Vision.Face
 6{
 7    /// <summary>
 8    /// Extension methods for Emotion.
 9    /// </summary>
 10    public static partial class EmotionExtensions
 11    {
 12        /// <summary>
 13        /// Create a sorted key-value pair of emotions and the corresponding scores, sorted from highest score on down.
 14        /// Sorting criteria: Score is the primary key sorted descending, and the name is the secondary key sorted alpha
 15        /// </summary>
 16        public static IEnumerable<KeyValuePair<string, double>> ToRankedList(this Emotion emotionScores)
 17        {
 418            return new Dictionary<string, double>()
 419            {
 420                { "Anger", emotionScores.Anger },
 421                { "Contempt", emotionScores.Contempt },
 422                { "Disgust", emotionScores.Disgust },
 423                { "Fear", emotionScores.Fear },
 424                { "Happiness", emotionScores.Happiness },
 425                { "Neutral", emotionScores.Neutral },
 426                { "Sadness", emotionScores.Sadness },
 427                { "Surprise", emotionScores.Surprise }
 428            }
 3629            .OrderByDescending(emotion => emotion.Value)
 3230            .ThenBy(emotion => emotion.Key);
 31        }
 32    }
 33}

Methods/Properties

ToRankedList(...)