< Summary

Class:Microsoft.Azure.CognitiveServices.Knowledge.QnAMaker.Models.QnADTO
Assembly:Microsoft.Azure.CognitiveServices.Knowledge.QnAMaker
File(s):C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Knowledge.QnAMaker\src\Generated\Models\QnADTO.cs
Covered lines:0
Uncovered lines:35
Coverable lines:35
Total lines:147
Line coverage:0% (0 of 35)
Covered branches:0
Total branches:22
Branch coverage:0% (0 of 22)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-0%100%
.ctor(...)-0%100%
get_Id()-0%100%
get_Answer()-0%100%
get_Source()-0%100%
get_Questions()-0%100%
get_Metadata()-0%100%
get_Context()-0%100%
Validate()-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\cognitiveservices\Knowledge.QnAMaker\src\Generated\Models\QnADTO.cs

#LineLine coverage
 1// <auto-generated>
 2// Copyright (c) Microsoft Corporation. All rights reserved.
 3// Licensed under the MIT License. See License.txt in the project root for
 4// license information.
 5//
 6// Code generated by Microsoft (R) AutoRest Code Generator.
 7// Changes may cause incorrect behavior and will be lost if the code is
 8// regenerated.
 9// </auto-generated>
 10
 11namespace Microsoft.Azure.CognitiveServices.Knowledge.QnAMaker.Models
 12{
 13    using Microsoft.Rest;
 14    using Newtonsoft.Json;
 15    using System.Collections;
 16    using System.Collections.Generic;
 17    using System.Linq;
 18
 19    /// <summary>
 20    /// Q-A object.
 21    /// </summary>
 22    public partial class QnADTO
 23    {
 24        /// <summary>
 25        /// Initializes a new instance of the QnADTO class.
 26        /// </summary>
 027        public QnADTO()
 28        {
 29            CustomInit();
 030        }
 31
 32        /// <summary>
 33        /// Initializes a new instance of the QnADTO class.
 34        /// </summary>
 35        /// <param name="answer">Answer text</param>
 36        /// <param name="questions">List of questions associated with the
 37        /// answer.</param>
 38        /// <param name="id">Unique id for the Q-A.</param>
 39        /// <param name="source">Source from which Q-A was indexed. eg.
 40        /// https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs</param>
 41        /// <param name="metadata">List of metadata associated with the
 42        /// answer.</param>
 43        /// <param name="context">Context of a QnA</param>
 044        public QnADTO(string answer, IList<string> questions, int? id = default(int?), string source = default(string), 
 45        {
 046            Id = id;
 047            Answer = answer;
 048            Source = source;
 049            Questions = questions;
 050            Metadata = metadata;
 051            Context = context;
 52            CustomInit();
 053        }
 54
 55        /// <summary>
 56        /// An initialization method that performs custom operations like setting defaults
 57        /// </summary>
 58        partial void CustomInit();
 59
 60        /// <summary>
 61        /// Gets or sets unique id for the Q-A.
 62        /// </summary>
 63        [JsonProperty(PropertyName = "id")]
 064        public int? Id { get; set; }
 65
 66        /// <summary>
 67        /// Gets or sets answer text
 68        /// </summary>
 69        [JsonProperty(PropertyName = "answer")]
 070        public string Answer { get; set; }
 71
 72        /// <summary>
 73        /// Gets or sets source from which Q-A was indexed. eg.
 74        /// https://docs.microsoft.com/en-us/azure/cognitive-services/QnAMaker/FAQs
 75        /// </summary>
 76        [JsonProperty(PropertyName = "source")]
 077        public string Source { get; set; }
 78
 79        /// <summary>
 80        /// Gets or sets list of questions associated with the answer.
 81        /// </summary>
 82        [JsonProperty(PropertyName = "questions")]
 083        public IList<string> Questions { get; set; }
 84
 85        /// <summary>
 86        /// Gets or sets list of metadata associated with the answer.
 87        /// </summary>
 88        [JsonProperty(PropertyName = "metadata")]
 089        public IList<MetadataDTO> Metadata { get; set; }
 90
 91        /// <summary>
 92        /// Gets or sets context of a QnA
 93        /// </summary>
 94        [JsonProperty(PropertyName = "context")]
 095        public QnADTOContext Context { get; set; }
 96
 97        /// <summary>
 98        /// Validate the object.
 99        /// </summary>
 100        /// <exception cref="ValidationException">
 101        /// Thrown if validation fails
 102        /// </exception>
 103        public virtual void Validate()
 104        {
 0105            if (Answer == null)
 106            {
 0107                throw new ValidationException(ValidationRules.CannotBeNull, "Answer");
 108            }
 0109            if (Questions == null)
 110            {
 0111                throw new ValidationException(ValidationRules.CannotBeNull, "Questions");
 112            }
 0113            if (Answer != null)
 114            {
 0115                if (Answer.Length > 25000)
 116                {
 0117                    throw new ValidationException(ValidationRules.MaxLength, "Answer", 25000);
 118                }
 0119                if (Answer.Length < 1)
 120                {
 0121                    throw new ValidationException(ValidationRules.MinLength, "Answer", 1);
 122                }
 123            }
 0124            if (Source != null)
 125            {
 0126                if (Source.Length > 300)
 127                {
 0128                    throw new ValidationException(ValidationRules.MaxLength, "Source", 300);
 129                }
 130            }
 0131            if (Metadata != null)
 132            {
 0133                foreach (var element in Metadata)
 134                {
 0135                    if (element != null)
 136                    {
 0137                        element.Validate();
 138                    }
 139                }
 140            }
 0141            if (Context != null)
 142            {
 0143                Context.Validate();
 144            }
 0145        }
 146    }
 147}