< Summary

Class:DCLPlugins.RealmsPlugin.RealmsPlugin
Assembly:DCL.Plugins.RealmsPlugin
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/RealmsPlugin/RealmsPlugin.cs
Covered lines:21
Uncovered lines:2
Coverable lines:23
Total lines:56
Line coverage:91.3% (21 of 23)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
RealmsPlugin()0%110100%
RealmListSet(...)0%2.152066.67%
RealmChanged(...)0%2.032080%
SetRealmModifiers()0%110100%
Dispose()0%220100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/DCLPlugins/RealmsPlugin/RealmsPlugin.cs

#LineLine coverage
 1using System.Collections.Generic;
 2using System.Linq;
 3using DCL;
 4using Decentraland.Bff;
 5using UnityEngine;
 6using Variables.RealmsInfo;
 7
 8namespace DCLPlugins.RealmsPlugin
 9{
 10    public class RealmsPlugin : IPlugin
 11    {
 3212        private BaseCollection<RealmModel> realmsList => DataStore.i.realm.realmsInfo;
 1213        private BaseVariable<AboutResponse> realmAboutConfiguration => DataStore.i.realm.playerRealmAbout;
 14        private AboutResponse currentConfiguration;
 15
 16        internal List<IRealmsModifier> realmsModifiers;
 17
 618        public RealmsPlugin()
 19        {
 620            realmsModifiers = new List<IRealmsModifier>() { new RealmsBlockerModifier(), new RealmsMinimapModifier() };
 21
 622            realmAboutConfiguration.OnChange += RealmChanged;
 623            realmsList.OnSet += RealmListSet;
 624        }
 25
 26        private void RealmListSet(IEnumerable<RealmModel> _)
 27        {
 628            if (currentConfiguration != null)
 029                SetRealmModifiers();
 630        }
 31
 32        private void RealmChanged(AboutResponse current, AboutResponse _)
 33        {
 1034            currentConfiguration = current;
 1035            if (realmsList.Count().Equals(0))
 036                return;
 37
 1038            SetRealmModifiers();
 1039        }
 40
 41        private void SetRealmModifiers()
 42        {
 1043            List<RealmModel> currentRealmsList = realmsList.Get().ToList();
 2044            bool isCatalyst = currentRealmsList.FirstOrDefault(r => r.serverName == currentConfiguration.Configurations.
 4045            realmsModifiers.ForEach(e => e.OnEnteredRealm(isCatalyst, currentConfiguration));
 1046        }
 47
 48        public void Dispose()
 49        {
 2450            realmsModifiers.ForEach(e => e.Dispose());
 51
 652            realmAboutConfiguration.OnChange -= RealmChanged;
 653            realmsList.OnSet -= RealmListSet;
 654        }
 55    }
 56}