< Summary

Information
Class: Spdx3.Model.Core.Classes.PositiveIntegerRange
Assembly: Spdx3
File(s): /home/runner/work/Spdx3/Spdx3/Spdx3/Model/Core/Classes/PositiveIntegerRange.cs
Line coverage
100%
Covered lines: 35
Uncovered lines: 0
Coverable lines: 35
Total lines: 96
Line coverage: 100%
Branch coverage
100%
Covered branches: 12
Total branches: 12
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
get_BeginIntegerRange()100%11100%
set_BeginIntegerRange(...)100%44100%
get_EndIntegerRange()100%11100%
set_EndIntegerRange(...)100%44100%
.ctor(...)100%44100%
Validate()100%11100%

File(s)

/home/runner/work/Spdx3/Spdx3/Spdx3/Model/Core/Classes/PositiveIntegerRange.cs

#LineLine coverage
 1using System.Diagnostics.CodeAnalysis;
 2using System.Text.Json.Serialization;
 3using Spdx3.Exceptions;
 4using Spdx3.Serialization;
 5using Spdx3.Utility;
 6
 7namespace Spdx3.Model.Core.Classes;
 8
 9/// <summary>
 10///     A mapping between prefixes and namespace partial URIs.
 11///     See https://spdx.github.io/spdx-spec/v3.0.1/model/Core/Classes/PositiveIntegerRange/
 12/// </summary>
 13public class PositiveIntegerRange : BaseModelClass
 14{
 1615    private int _beginIntegerRange = 1;
 16
 1617    private int _endIntegerRange = int.MaxValue;
 18
 19    [JsonPropertyName("beginIntegerRange")]
 20    [JsonConverter(typeof(SpdxModelConverterFactory))]
 21    public required int BeginIntegerRange
 22    {
 523        get => _beginIntegerRange;
 24        set
 25        {
 1426            if (value < 1)
 27            {
 228                throw new Spdx3Exception($"Value of {value} is not a positive non-zero integer",
 229                    new ArgumentOutOfRangeException(nameof(BeginIntegerRange)));
 30            }
 31
 1232            if (value > _endIntegerRange)
 33            {
 134                throw new Spdx3Exception($"Value of {value} cannot exceed end integer value of {_endIntegerRange}",
 135                    new ArgumentOutOfRangeException(nameof(BeginIntegerRange)));
 36            }
 37
 1138            _beginIntegerRange = value;
 1139        }
 40    }
 41
 42
 43    [JsonPropertyName("endIntegerRange")]
 44    [JsonConverter(typeof(SpdxModelConverterFactory))]
 45    public required int EndIntegerRange
 46    {
 547        get => _endIntegerRange;
 48        set
 49        {
 1450            if (value < 1)
 51            {
 252                throw new Spdx3Exception($"Value of {value} is not a positive non-zero integer",
 253                    new ArgumentOutOfRangeException(nameof(EndIntegerRange)));
 54            }
 55
 1256            if (value < _beginIntegerRange)
 57            {
 158                throw new Spdx3Exception(
 159                    $"Value of {value} cannot be less than begin integer value of {_beginIntegerRange}",
 160                    new ArgumentOutOfRangeException(nameof(EndIntegerRange)));
 61            }
 62
 1163            _endIntegerRange = value;
 1164        }
 65    }
 66
 67    // protected internal no-parm constructor required for deserialization
 68    // ReSharper disable once UnusedMember.Global
 369    protected internal PositiveIntegerRange()
 70    {
 371    }
 72
 73    [SetsRequiredMembers]
 1374    public PositiveIntegerRange(Catalog catalog, int beginIntegerRange, int endIntegerRange) : base(catalog)
 75    {
 1376        if (beginIntegerRange < 1)
 77        {
 278            throw new Spdx3Exception("beginIntegerRange must be a positive, non-zero integer");
 79        }
 80
 1181        if (endIntegerRange < beginIntegerRange)
 82        {
 183            throw new Spdx3Exception("endIntegerRange must be >= beginIntegerRange");
 84        }
 85
 1086        BeginIntegerRange = beginIntegerRange;
 1087        EndIntegerRange = endIntegerRange;
 1088    }
 89
 90    public override void Validate()
 91    {
 292        base.Validate();
 193        ValidateRequiredProperty(nameof(BeginIntegerRange));
 194        ValidateRequiredProperty(nameof(EndIntegerRange));
 195    }
 96}