< Summary - pva.SuperV

Information
Class: pva.SuperV.Engine.Instance
Assembly: pva.SuperV.Engine
File(s): /home/runner/work/pva.SuperV/pva.SuperV/pva.SuperV.Engine/Instance.cs
Tag: dotnet-ubuntu_18869653307
Line coverage
100%
Covered lines: 23
Uncovered lines: 0
Coverable lines: 23
Total lines: 85
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Name()100%11100%
get_Class()100%11100%
get_Fields()100%11100%
Dispose()100%11100%
Dispose(...)100%11100%
GetField(...)100%22100%
GetField(...)100%22100%

File(s)

/home/runner/work/pva.SuperV/pva.SuperV/pva.SuperV.Engine/Instance.cs

#LineLine coverage
 1using pva.SuperV.Engine.Exceptions;
 2
 3namespace pva.SuperV.Engine
 4{
 5    /// <summary>
 6    /// Generated instance.
 7    /// </summary>
 8    /// <seealso cref="pva.SuperV.Engine.IInstance" />
 9    public class Instance : IInstance
 10    {
 11        /// <summary>
 12        /// Gets or sets the name of the instance.
 13        /// </summary>
 14        /// <value>
 15        /// The name.
 16        /// </value>
 23917        public string Name { get; set; } = null!;
 18
 19        /// <summary>
 20        /// Gets or sets the class of the instance.
 21        /// </summary>
 22        /// <value>
 23        /// The class.
 24        /// </value>
 28225        public Class Class { get; set; } = null!;
 26
 27        /// <summary>
 28        /// Gets or sets the fields contained in instance.
 29        /// </summary>
 30        /// <value>
 31        /// The fields.
 32        /// </value>
 186533        public Dictionary<string, IField> Fields { get; set; } = [];
 34
 35        /// <summary>
 36        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 37        /// </summary>
 38        public void Dispose()
 9739        {
 9740            Dispose(true);
 9741            GC.SuppressFinalize(this);
 9742        }
 43
 44        /// <summary>
 45        /// Releases unmanaged and - optionally - managed resources.
 46        /// </summary>
 47        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release
 48        protected virtual void Dispose(bool disposing)
 9749        {
 9750            Fields.Clear();
 9751        }
 52
 53        /// <summary>
 54        /// Gets a field of the instance.
 55        /// </summary>
 56        /// <typeparam name="T"></typeparam>
 57        /// <param name="fieldName">Name of the field.</param>
 58        /// <returns>The field.</returns>
 59        /// <exception cref="pva.SuperV.Engine.Exceptions.WrongFieldTypeException"></exception>
 60        public Field<T>? GetField<T>(string fieldName)
 10661        {
 10662            IField field = GetField(fieldName);
 10563            if (field.Type != typeof(T))
 164            {
 165                throw new WrongFieldTypeException(fieldName, field.Type, typeof(T));
 66            }
 10467            return field as Field<T>;
 10468        }
 69
 70        /// <summary>
 71        /// Gets a field of the instance.
 72        /// </summary>
 73        /// <param name="fieldName">Name of the field.</param>
 74        /// <returns>The field.</returns>
 75        /// <exception cref="pva.SuperV.Engine.Exceptions.UnknownEntityException"></exception>
 76        public IField GetField(string fieldName)
 57777        {
 57778            if (Fields.TryGetValue(fieldName, out var field))
 57679            {
 57680                return field;
 81            }
 182            throw new UnknownEntityException(fieldName, Class.Name);
 57683        }
 84    }
 85}