< Summary

Class:Azure.AI.FormRecognizer.Models.TrainResult
Assembly:Azure.AI.FormRecognizer
File(s):C:\Git\azure-sdk-for-net\sdk\formrecognizer\Azure.AI.FormRecognizer\src\Generated\Models\TrainResult.cs
C:\Git\azure-sdk-for-net\sdk\formrecognizer\Azure.AI.FormRecognizer\src\Generated\Models\TrainResult.Serialization.cs
Covered lines:36
Uncovered lines:7
Coverable lines:43
Total lines:120
Line coverage:83.7% (36 of 43)
Covered branches:16
Total branches:18
Branch coverage:88.8% (16 of 18)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
.ctor(...)-100%100%
get_TrainingDocuments()-100%100%
get_Fields()-100%100%
get_AverageModelAccuracy()-100%100%
get_Errors()-100%100%
DeserializeTrainResult(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\formrecognizer\Azure.AI.FormRecognizer\src\Generated\Models\TrainResult.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System;
 9using System.Collections.Generic;
 10using System.Linq;
 11using Azure.AI.FormRecognizer.Training;
 12using Azure.Core;
 13
 14namespace Azure.AI.FormRecognizer.Models
 15{
 16    /// <summary> Custom model training result. </summary>
 17    internal partial class TrainResult
 18    {
 19        /// <summary> Initializes a new instance of TrainResult. </summary>
 20        /// <param name="trainingDocuments"> List of the documents used to train the model and any errors reported in ea
 21        /// <exception cref="ArgumentNullException"> <paramref name="trainingDocuments"/> is null. </exception>
 022        internal TrainResult(IEnumerable<TrainingDocumentInfo> trainingDocuments)
 23        {
 024            if (trainingDocuments == null)
 25            {
 026                throw new ArgumentNullException(nameof(trainingDocuments));
 27            }
 28
 029            TrainingDocuments = trainingDocuments.ToList();
 030            Fields = new ChangeTrackingList<CustomFormModelField>();
 031            Errors = new ChangeTrackingList<FormRecognizerError>();
 032        }
 33
 34        /// <summary> Initializes a new instance of TrainResult. </summary>
 35        /// <param name="trainingDocuments"> List of the documents used to train the model and any errors reported in ea
 36        /// <param name="fields"> List of fields used to train the model and the train operation error reported by each.
 37        /// <param name="averageModelAccuracy"> Average accuracy. </param>
 38        /// <param name="errors"> Errors returned during the training operation. </param>
 14839        internal TrainResult(IReadOnlyList<TrainingDocumentInfo> trainingDocuments, IReadOnlyList<CustomFormModelField> 
 40        {
 14841            TrainingDocuments = trainingDocuments;
 14842            Fields = fields;
 14843            AverageModelAccuracy = averageModelAccuracy;
 14844            Errors = errors;
 14845        }
 46
 47        /// <summary> List of the documents used to train the model and any errors reported in each document. </summary>
 14048        public IReadOnlyList<TrainingDocumentInfo> TrainingDocuments { get; }
 49        /// <summary> List of fields used to train the model and the train operation error reported by each. </summary>
 13650        public IReadOnlyList<CustomFormModelField> Fields { get; }
 51        /// <summary> Average accuracy. </summary>
 6852        public float? AverageModelAccuracy { get; }
 53        /// <summary> Errors returned during the training operation. </summary>
 14854        public IReadOnlyList<FormRecognizerError> Errors { get; }
 55    }
 56}

C:\Git\azure-sdk-for-net\sdk\formrecognizer\Azure.AI.FormRecognizer\src\Generated\Models\TrainResult.Serialization.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System.Collections.Generic;
 9using System.Text.Json;
 10using Azure.AI.FormRecognizer.Training;
 11using Azure.Core;
 12
 13namespace Azure.AI.FormRecognizer.Models
 14{
 15    internal partial class TrainResult
 16    {
 17        internal static TrainResult DeserializeTrainResult(JsonElement element)
 18        {
 14819            IReadOnlyList<TrainingDocumentInfo> trainingDocuments = default;
 14820            Optional<IReadOnlyList<CustomFormModelField>> fields = default;
 14821            Optional<float> averageModelAccuracy = default;
 14822            Optional<IReadOnlyList<FormRecognizerError>> errors = default;
 116023            foreach (var property in element.EnumerateObject())
 24            {
 43225                if (property.NameEquals("trainingDocuments"))
 26                {
 14827                    List<TrainingDocumentInfo> array = new List<TrainingDocumentInfo>();
 166428                    foreach (var item in property.Value.EnumerateArray())
 29                    {
 68430                        array.Add(TrainingDocumentInfo.DeserializeTrainingDocumentInfo(item));
 31                    }
 14832                    trainingDocuments = array;
 14833                    continue;
 34                }
 28435                if (property.NameEquals("fields"))
 36                {
 6837                    List<CustomFormModelField> array = new List<CustomFormModelField>();
 198438                    foreach (var item in property.Value.EnumerateArray())
 39                    {
 92440                        array.Add(CustomFormModelField.DeserializeCustomFormModelField(item));
 41                    }
 6842                    fields = array;
 6843                    continue;
 44                }
 21645                if (property.NameEquals("averageModelAccuracy"))
 46                {
 6847                    averageModelAccuracy = property.Value.GetSingle();
 6848                    continue;
 49                }
 14850                if (property.NameEquals("errors"))
 51                {
 14852                    List<FormRecognizerError> array = new List<FormRecognizerError>();
 31253                    foreach (var item in property.Value.EnumerateArray())
 54                    {
 855                        array.Add(FormRecognizerError.DeserializeFormRecognizerError(item));
 56                    }
 14857                    errors = array;
 58                    continue;
 59                }
 60            }
 14861            return new TrainResult(trainingDocuments, Optional.ToList(fields), Optional.ToNullable(averageModelAccuracy)
 62        }
 63    }
 64}