< Summary

Class:GDX.Threading.WaitWhile
Assembly:GDX
File(s):./Packages/com.dotbunny.gdx/GDX/Threading/WaitWhile.cs
Covered lines:15
Uncovered lines:0
Coverable lines:15
Total lines:44
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/WaitWhile.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;
 6using System.Collections;
 7using System.Threading.Tasks;
 8
 9namespace GDX.Threading
 10{
 11    /// <summary>
 12    ///     Some useful wait while methods to control program flow.
 13    /// </summary>
 14    public static class WaitWhile
 15    {
 16        /// <summary>
 17        ///     Wait using an <see cref="IEnumerator" /> while the <paramref name="conditional" /> is true.
 18        /// </summary>
 19        /// <param name="conditional">A function evaluated to determine if the wait continues.</param>
 20        /// <returns>Yields null values.</returns>
 21        public static IEnumerator GetEnumerator(Func<bool> conditional)
 122        {
 223            while (conditional())
 124            {
 125                yield return null;
 126            }
 127        }
 28
 29        /// <summary>
 30        ///     Wait asynchronously while the <paramref name="conditional" /> is true.
 31        /// </summary>
 32        /// <param name="conditional">A function evaluated to determine if the wait continues.</param>
 33        public static async Task GetTask(Func<bool> conditional)
 134        {
 335            await Task.Run(() =>
 136            {
 1937                while (conditional())
 1838                {
 1839                    Task.Delay(1).Wait();
 1840                }
 141            });
 142        }
 43    }
 44}

Coverage by test methods



Methods/Properties

GetEnumerator()
GetTask()