< Summary

Information
Class: MyNet.Primitives.Sequences.IntegerSequence
Assembly: MyNet.Primitives
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Primitives/Sequences/IntegerSequence.cs
Tag: 323_28699572109
Line coverage
100%
Covered lines: 3
Uncovered lines: 0
Coverable lines: 3
Total lines: 45
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
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_NextValue()100%11100%
SetCurrentValue(...)100%11100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Primitives/Sequences/IntegerSequence.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="IntegerSequence.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7namespace MyNet.Primitives.Sequences;
 8
 9/// <summary>
 10/// A simple sequence generator. Note: it is NOT thread-safe.
 11/// </summary>
 12/// <remarks>
 13/// Initializes a new instance of the <see cref="IntegerSequence"/> class.
 14/// </remarks>
 15/// <param name="seed">The sequence initial value.</param>
 16public class IntegerSequence(uint seed) : ISequence<uint>
 17{
 18    /// <summary>
 19    /// Initializes a new instance of the <see cref="IntegerSequence"/> class.
 20    /// The sequence's initial current value is 0.
 21    /// </summary>
 22    public IntegerSequence()
 623        : this(0u) { }
 24
 25    /// <summary>
 26    /// Gets this sequence's current value.
 27    /// </summary>
 28    public uint CurrentValue { get; private set; } = seed;
 29
 30    /// <summary>
 31    /// Gets computes and retrieves this sequence's next value.
 32    /// </summary>
 33    /// <remarks>
 34    /// When called, the value of <see cref="CurrentValue"/> is updated.
 35    /// </remarks>
 636    public uint NextValue => ++CurrentValue;
 37
 38    /// <summary>
 39    /// Sets the current value to the specified value.
 40    /// Subsequent call to <see cref="NextValue"/> will return this <paramref name="value"/> + 1.
 41    /// </summary>
 42    /// <param name="value">The new sequence current value.</param>
 343    public void SetCurrentValue(uint value) => CurrentValue = value;
 44}
 45