< Summary

Class:GDX.Threading.WaitFor
Assembly:GDX
File(s):./Packages/com.dotbunny.gdx/GDX/Threading/WaitFor.cs
Covered lines:15
Uncovered lines:0
Coverable lines:15
Total lines:80
Line coverage:100% (15 of 15)
Covered branches:0
Total branches:0
Covered methods:2
Total methods:2
Method coverage:100% (2 of 2)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GetEnumerator()0%440100%
GetTask()0%330100%

File(s)

./Packages/com.dotbunny.gdx/GDX/Threading/WaitFor.cs

#LineLine coverage
 1// Copyright (c) 2020-2024 dotBunny Inc.
 2// dotBunny licenses this file to you under the BSL-1.0 license.
 3// See the LICENSE file in the project root for more information.
 4
 5using System.Collections;
 6using System.Diagnostics;
 7using System.Threading.Tasks;
 8
 9namespace GDX.Threading
 10{
 11    /// <summary>
 12    ///     Some useful wait for methods to control program flow.
 13    /// </summary>
 14    public static class WaitFor
 15    {
 16        /// <summary>
 17        ///     One second worth of milliseconds.
 18        /// </summary>
 19        public const int OneSecond = 1000;
 20
 21        /// <summary>
 22        ///     Two seconds worth of milliseconds.
 23        /// </summary>
 24        public const int TwoSeconds = 2000;
 25
 26        /// <summary>
 27        ///     Five seconds worth of milliseconds.
 28        /// </summary>
 29        public const int FiveSeconds = 5000;
 30
 31        /// <summary>
 32        ///     Ten seconds worth of milliseconds.
 33        /// </summary>
 34        public const int TenSeconds = 10000;
 35
 36        /// <summary>
 37        ///     Thirty seconds worth of milliseconds.
 38        /// </summary>
 39        public const int ThirtySeconds = 30000;
 40
 41        /// <summary>
 42        ///     One minute worth of milliseconds.
 43        /// </summary>
 44        public const int OneMinute = 60000;
 45
 46        /// <summary>
 47        ///     Ten minutes worth of milliseconds.
 48        /// </summary>
 49        public const int TenMinutes = 600000;
 50
 51        /// <summary>
 52        ///     Wait using an <see cref="IEnumerator" />.
 53        /// </summary>
 54        /// <param name="milliseconds">The number of milliseconds to wait for.</param>
 55        /// <returns>Yields null values.</returns>
 56        public static IEnumerator GetEnumerator(int milliseconds)
 957        {
 958            Stopwatch stopwatch = new Stopwatch();
 959            stopwatch.Restart();
 495460            while (stopwatch.ElapsedMilliseconds < milliseconds)
 494561            {
 494562                yield return null;
 494563            }
 64
 965            stopwatch.Stop();
 966        }
 67
 68        /// <summary>
 69        ///     Wait asynchronously.
 70        /// </summary>
 71        /// <param name="milliseconds">The number of milliseconds to wait for.</param>
 72        public static async Task GetTask(int milliseconds)
 173        {
 374            await Task.Run(() =>
 175            {
 176                Task.Delay(milliseconds).Wait();
 177            });
 178        }
 79    }
 80}

Coverage by test methods









Methods/Properties

GetEnumerator()
GetTask()