< Summary

Class:DCL.Controllers.LoadingScreenV2.RemoteHintRequestSource
Assembly:DCL.LoadingScreenV2
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/LoadingScreenV2/HintServiceScripts/RemoteHintRequestSource.cs
Covered lines:0
Uncovered lines:19
Coverable lines:19
Total lines:50
Line coverage:0% (0 of 19)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:8
Method coverage:0% (0 of 8)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
RemoteHintRequestSource(...)0%2100%
GetHintsAsync()0%30500%
Dispose()0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/LoadingScreenV2/HintServiceScripts/RemoteHintRequestSource.cs

#LineLine coverage
 1using Cysharp.Threading.Tasks;
 2using System;
 3using System.Collections.Generic;
 4using System.Threading;
 5using UnityEngine;
 6
 7namespace DCL.Controllers.LoadingScreenV2
 8{
 9    /// <summary>
 10    ///     RemoteHintRequestSource provides remote hint request functionality.
 11    ///     It retrieves hints asynchronously from a specified source URL using an ISourceWebRequestHandler.
 12    ///     The hints are parsed from the received JSON data using HintSceneParserUtil.
 13    /// </summary>
 14    public class RemoteHintRequestSource : IHintRequestSource
 15    {
 016        public RemoteHintRequestSource(string sourceUrlJson, SourceTag sourceTag, ISourceWebRequestHandler webRequestHan
 17        {
 018            Source = sourceUrlJson;
 019            this.SourceTag = sourceTag;
 020            LoadingHints = new List<Hint>();
 021            this.webRequestHandler = webRequestHandler;
 022        }
 23
 024        public ISourceWebRequestHandler webRequestHandler { get; }
 025        public string Source { get; }
 026        public SourceTag SourceTag { get; }
 027        public List<Hint> LoadingHints { get; private set; }
 28
 29        public async UniTask<List<Hint>> GetHintsAsync(CancellationToken ctx)
 30        {
 31            try
 32            {
 33                // If the CancellationToken is already canceled, return an empty list.
 034                if (ctx.IsCancellationRequested) { return LoadingHints; }
 35
 036                string json = await webRequestHandler.Get(Source);
 37
 038                if (!string.IsNullOrEmpty(json)) { LoadingHints = HintSceneParserUtil.ParseJsonToHints(json); }
 039            }
 040            catch (Exception ex) { Debug.LogWarning($"Exception in RemoteHintRequestSource.GetHintsAsync: {ex.Message}\n
 41
 042            return LoadingHints;
 043        }
 44
 45        public void Dispose()
 46        {
 047            LoadingHints.Clear();
 048        }
 49    }
 50}