< Summary

Class:DCL.UpdateDispatcher
Assembly:UpdateEventHandler
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/UpdateEventHandler/UpdateDispatcher.cs
Covered lines:32
Uncovered lines:3
Coverable lines:35
Total lines:85
Line coverage:91.4% (32 of 35)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
UpdateEventCollection()0%110100%
Add(...)0%2.032080%
Remove(...)0%2.032080%
Contains(...)0%2100%
UpdateDispatcher()0%110100%
Awake()0%110100%
EnsureEventType(...)0%220100%
Dispatch(...)0%220100%
Update()0%110100%
LateUpdate()0%110100%
FixedUpdate()0%110100%
OnGUI()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/UpdateEventHandler/UpdateDispatcher.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using UnityEngine;
 4
 5namespace DCL
 6{
 7    public class UpdateDispatcher : MonoBehaviour
 8    {
 9        public class UpdateEventCollection
 10        {
 223211            public HashSet<Action> eventHashset = new HashSet<Action>();
 223212            public List<Action> eventList = new List<Action>();
 13
 14            public void Add(Action action)
 15            {
 221016                if ( eventHashset.Contains(action))
 017                    return;
 18
 221019                eventList.Add(action);
 221020                eventHashset.Add(action);
 221021            }
 22
 23            public void Remove(Action action)
 24            {
 20325                if ( !eventHashset.Contains(action))
 026                    return;
 27
 20328                eventList.Remove(action);
 20329                eventHashset.Remove(action);
 20330            }
 31
 32            public bool Contains(Action action)
 33            {
 034                return eventHashset.Contains(action);
 35            }
 36        }
 37
 55838        public Dictionary<IUpdateEventHandler.EventType, UpdateEventCollection> eventCollections = new Dictionary<IUpdat
 39
 40        void Awake()
 41        {
 55842            EnsureEventType(IUpdateEventHandler.EventType.Update);
 55843            EnsureEventType(IUpdateEventHandler.EventType.LateUpdate);
 55844            EnsureEventType(IUpdateEventHandler.EventType.FixedUpdate);
 55845            EnsureEventType(IUpdateEventHandler.EventType.OnGui);
 55846        }
 47
 48        void EnsureEventType( IUpdateEventHandler.EventType eventType )
 49        {
 223250            if ( !eventCollections.ContainsKey(eventType) )
 223251                eventCollections.Add(eventType, new UpdateEventCollection());
 223252        }
 53
 54        void Dispatch( IUpdateEventHandler.EventType eventType )
 55        {
 9149556            var list = eventCollections[eventType].eventList;
 9149557            int count = eventCollections[eventType].eventList.Count;
 58
 46966459            for ( int i = 0; i < count; i++ )
 60            {
 14333761                list[i].Invoke();
 62            }
 9149563        }
 64
 65        void Update()
 66        {
 4367367            Dispatch(IUpdateEventHandler.EventType.Update);
 4367368        }
 69
 70        void LateUpdate()
 71        {
 4367372            Dispatch(IUpdateEventHandler.EventType.LateUpdate);
 4367373        }
 74
 75        void FixedUpdate()
 76        {
 283377            Dispatch(IUpdateEventHandler.EventType.FixedUpdate);
 283378        }
 79
 80        void OnGUI()
 81        {
 131682            Dispatch(IUpdateEventHandler.EventType.OnGui);
 131683        }
 84    }
 85}