< Summary

Class:AvatarAssets.SceneEmoteHelper
Assembly:AvatarAssets
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Models/AvatarAssets/SceneEmoteHelper.cs
Covered lines:0
Uncovered lines:18
Coverable lines:18
Total lines:51
Line coverage:0% (0 of 18)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:3
Method coverage:0% (0 of 3)

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
TryGenerateEmoteId(...)0%20400%
TryGetDataFromEmoteId(...)0%2100%
IsSceneEmote(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Models/AvatarAssets/SceneEmoteHelper.cs

#LineLine coverage
 1using Cysharp.Threading.Tasks;
 2using DCL.Controllers;
 3using DCL.Emotes;
 4using System;
 5using System.Collections.Generic;
 6using System.Threading;
 7
 8namespace AvatarAssets
 9{
 10    public static class SceneEmoteHelper
 11    {
 12        public const string SCENE_EMOTE_PREFIX = "urn:decentraland:off-chain:scene-emote:";
 13
 14        public static bool TryGenerateEmoteId(IParcelScene scene, string emoteFilePath, bool loop, out string emoteId)
 15        {
 016            if (scene.contentProvider.TryGetContentHash(emoteFilePath, out string emoteHash))
 17            {
 018                emoteId = $"{SCENE_EMOTE_PREFIX}{emoteHash}-{(loop ? "true" : "false")}";
 019                return true;
 20            }
 21
 022            emoteId = string.Empty;
 023            return false;
 24        }
 25
 26        public static bool TryGetDataFromEmoteId(string emoteId, out string emoteHash, out bool loop)
 27        {
 28            try
 29            {
 030                ReadOnlySpan<char> prefixRemoved = emoteId.AsSpan().Slice(SCENE_EMOTE_PREFIX.Length, emoteId.Length - SC
 031                int loopSeparator = prefixRemoved.LastIndexOf('-');
 032                emoteHash = prefixRemoved.Slice(0, loopSeparator).ToString();
 33
 034                var loopSpan = prefixRemoved.Slice(loopSeparator + 1, 4);
 035                loop = loopSpan.Equals("true", StringComparison.InvariantCultureIgnoreCase);
 36
 037                return true;
 38            }
 039            catch (Exception _)
 40            {
 041                emoteHash = string.Empty;
 042                loop = false;
 043            }
 44
 045            return false;
 046        }
 47
 48        public static bool IsSceneEmote(string emoteId) =>
 049            emoteId.Contains(SCENE_EMOTE_PREFIX, StringComparison.OrdinalIgnoreCase);
 50    }
 51}