< 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    {
 2412        private BaseCollection<RealmModel> realmsList => DataStore.i.realm.realmsInfo;
 813        private BaseVariable<AboutResponse> realmAboutConfiguration => DataStore.i.realm.playerRealmAbout;
 14        private AboutResponse currentConfiguration;
 15
 16        internal List<IRealmsModifier> realmsModifiers;
 17
 418        public RealmsPlugin()
 19        {
 420            realmsModifiers = new List<IRealmsModifier>() { new RealmsBlockerModifier() };
 21
 422            realmAboutConfiguration.OnChange += RealmChanged;
 423            realmsList.OnSet += RealmListSet;
 424        }
 25
 26        private void RealmListSet(IEnumerable<RealmModel> _)
 27        {
 428            if (currentConfiguration != null)
 029                SetRealmModifiers();
 430        }
 31
 32        private void RealmChanged(AboutResponse current, AboutResponse _)
 33        {
 834            currentConfiguration = current;
 835            if (realmsList.Count().Equals(0))
 036                return;
 37
 838            SetRealmModifiers();
 839        }
 40
 41        private void SetRealmModifiers()
 42        {
 843            List<RealmModel> currentRealmsList = realmsList.Get().ToList();
 1644            bool isCatalyst = currentRealmsList.FirstOrDefault(r => r.serverName == currentConfiguration.Configurations.
 2445            realmsModifiers.ForEach(e => e.OnEnteredRealm(isCatalyst, currentConfiguration));
 846        }
 47
 48        public void Dispose()
 49        {
 1250            realmsModifiers.ForEach(e => e.Dispose());
 51
 452            realmAboutConfiguration.OnChange -= RealmChanged;
 453            realmsList.OnSet -= RealmListSet;
 454        }
 55    }
 56}