< Summary

Class:LandsController
Assembly:BuilderProjectsPanel
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/ProjectsPanelHUD/Scripts/LandController/LandController.cs
Covered lines:0
Uncovered lines:8
Coverable lines:8
Total lines:59
Line coverage:0% (0 of 8)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
SetLands(...)0%6200%
AddListener(...)0%2100%
RemoveListener(...)0%2100%
GetLands()0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/BuilderInWorld/HUD/ProjectsPanelHUD/Scripts/LandController/LandController.cs

#LineLine coverage
 1using System;
 2
 3/// <summary>
 4/// This interface is responsible to handle the lands of builder in world panel.
 5/// It will handle the listeners that will add/remove projects to the list
 6/// </summary>
 7internal interface ILandsController
 8{
 9    /// <summary>
 10    /// This action will be called each time that we changes the land list
 11    /// </summary>
 12    event Action<LandWithAccess[]> OnLandsSet;
 13
 14    /// <summary>
 15    /// This will set the land list
 16    /// </summary>
 17    /// <param name="lands"></param>
 18    void SetLands(LandWithAccess[] lands);
 19
 20    /// <summary>
 21    /// This will add a listener that will be responsible to add/remove lands
 22    /// </summary>
 23    /// <param name="listener"></param>
 24    void AddListener(ILandsListener listener);
 25
 26    /// <summary>
 27    /// This will remove a listener that will be responsible to add/remove lands
 28    /// </summary>
 29    /// <param name="listener"></param>
 30    void RemoveListener(ILandsListener listener);
 31
 32    /// <summary>
 33    /// This will return all the lands that we have access
 34    /// </summary>
 35    /// <returns>An array with the lands that we have access</returns>
 36    LandWithAccess[] GetLands();
 37}
 38
 39internal class LandsController : ILandsController
 40{
 41    public event Action<LandWithAccess[]> OnLandsSet;
 42
 43    private LandWithAccess[] userLands = null;
 44
 45    void ILandsController.SetLands(LandWithAccess[] lands)
 46    {
 047        userLands = lands;
 048        OnLandsSet?.Invoke(lands);
 049    }
 50
 51    void ILandsController.AddListener(ILandsListener listener)
 52    {
 053        OnLandsSet += listener.OnSetLands;
 054        listener.OnSetLands(userLands);
 055    }
 56
 057    void ILandsController.RemoveListener(ILandsListener listener) { OnLandsSet -= listener.OnSetLands; }
 058    public LandWithAccess[] GetLands() { return userLands; }
 59}