• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JaCraig / Mirage / 18512640106

14 Oct 2025 11:14PM UTC coverage: 88.373% (+0.04%) from 88.332%
18512640106

push

github

web-flow
Merge pull request #352 from JaCraig/dependabot/nuget/Mirage.Tests/dependencies-c6472eee05

chore: Bump the dependencies group with 1 update

554 of 860 branches covered (64.42%)

Branch coverage included in aggregate %.

3839 of 4111 relevant lines covered (93.38%)

34730.4 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

69.7
/Mirage/Generators/Default/Nullable/NullableULongGenerator.cs
1
/*
2
Copyright 2017 James Craig
3

4
Licensed under the Apache License, Version 2.0 (the "License");
5
you may not use this file except in compliance with the License.
6
You may obtain a copy of the License at
7

8
    http://www.apache.org/licenses/LICENSE-2.0
9

10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations under the License.
15
*/
16

17
using Mirage.Generators.BaseClasses;
18
using Mirage.Interfaces;
19
using System;
20
using System.Collections.Generic;
21

22
namespace Mirage.Generators.Default.Nullable
23
{
24
    /// <summary>
25
    /// ULong generator
26
    /// </summary>
27
    /// <seealso cref="GeneratorAttributeBase"/>
28
    /// <seealso cref="IGenerator{ULong}"/>
29
    public sealed class NullableULongGeneratorAttribute : GeneratorAttributeBase, IGenerator<ulong?>
30
    {
31
        /// <summary>
32
        /// Initializes a new instance of the <see cref="NullableULongGeneratorAttribute"/> class.
33
        /// </summary>
34
        /// <param name="min">The minimum.</param>
35
        /// <param name="max">The maximum.</param>
36
        public NullableULongGeneratorAttribute(ulong min, ulong max)
37
            : base(min == 0 && max == 0 ? ulong.MinValue : min, min == 0 && max == 0 ? ulong.MaxValue : max)
5!
38
        {
39
        }
5✔
40

41
        /// <summary>
42
        /// Initializes a new instance of the <see cref="NullableULongGeneratorAttribute"/> class.
43
        /// </summary>
44
        public NullableULongGeneratorAttribute()
45
            : this(ulong.MinValue, ulong.MaxValue)
5✔
46
        {
47
        }
5✔
48

49
        /// <summary>
50
        /// Gets a value indicating whether this <see cref="IGenerator"/> is a default one.
51
        /// </summary>
52
        /// <value><c>true</c> if default; otherwise, <c>false</c>.</value>
53
        public override bool Default => true;
2✔
54

55
        /// <summary>
56
        /// Gets the type generated.
57
        /// </summary>
58
        /// <value>The type generated.</value>
59
        public override Type TypeGenerated => typeof(ulong?);
3✔
60

61
        /// <summary>
62
        /// Generates a random value of the specified type
63
        /// </summary>
64
        /// <param name="rand">Random number generator that it can use</param>
65
        /// <returns>A randomly generated object of the specified type</returns>
66
        public ulong? Next(Random rand)
67
        {
68
            return !(rand?.Next<bool>() ?? false) ? null : (ulong?)rand.Next<ulong>();
128✔
69
        }
70

71
        /// <summary>
72
        /// Generates a random value of the specified type
73
        /// </summary>
74
        /// <param name="rand">Random number generator that it can use</param>
75
        /// <param name="min">Minimum value (inclusive)</param>
76
        /// <param name="max">Maximum value (inclusive)</param>
77
        /// <returns>A randomly generated object of the specified type</returns>
78
        public ulong? Next(Random rand, ulong? min, ulong? max)
79
        {
80
            if (!(rand?.Next<bool>() ?? false))
2!
81
                return null;
2✔
82
            min ??= ulong.MinValue;
×
83
            max ??= ulong.MaxValue;
×
84
            return rand.Next(min.Value, max.Value);
×
85
        }
86

87
        /// <summary>
88
        /// Generates next object
89
        /// </summary>
90
        /// <param name="rand">The rand.</param>
91
        /// <param name="previouslySeen">The previously seen.</param>
92
        /// <returns>The next object</returns>
93
        public override object? NextObj(Random rand, List<object> previouslySeen)
94
        {
95
            return Next(rand);
25✔
96
        }
97
    }
98
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc