< Summary

Class:UsersSearchBridge
Assembly:UsersSearchBridge
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Bridges/UsersSearchBridge/UsersSearchBridge.cs
Covered lines:3
Uncovered lines:9
Coverable lines:12
Total lines:52
Line coverage:25% (3 of 12)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
Awake()0%2.262060%
SetENSOwnerQueryResult(...)0%20400%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Bridges/UsersSearchBridge/UsersSearchBridge.cs

#LineLine coverage
 1using System;
 2using DCL.Helpers;
 3using UnityEngine;
 4
 5public delegate void OnSearchResultDelegate (string searchInput, UserProfileModel[] profiles);
 6
 7public interface IUsersSearchBridge
 8{
 9    event OnSearchResultDelegate OnSearchResult;
 10}
 11
 12public class UsersSearchBridge : MonoBehaviour, IUsersSearchBridge
 13{
 14    public event OnSearchResultDelegate OnSearchResult;
 15
 016    public static UsersSearchBridge i { get; private set; }
 17
 18    void Awake()
 19    {
 5220        if (i != null)
 21        {
 022            Utils.SafeDestroy(this);
 023            return;
 24        }
 25
 5226        i = this;
 5227    }
 28
 29    /// <summary>
 30    /// Called by kernel when a query for ENS owners has finished
 31    /// </summary>
 32    /// <param name="payload">query result sent by kernel</param>
 33    public void SetENSOwnerQueryResult(string payload)
 34    {
 035        ResultPayload result = Utils.SafeFromJson<ResultPayload>(payload);
 36
 037        UserProfileModel[] profiles = null;
 038        if (result.success && result.profiles.Length > 0)
 39        {
 040            profiles = result.profiles;
 41        }
 042        OnSearchResult?.Invoke(result.searchInput, profiles);
 043    }
 44
 45    [Serializable]
 46    class ResultPayload
 47    {
 48        public string searchInput;
 49        public bool success;
 50        public UserProfileModel[] profiles;
 51    }
 52}