< Summary

Class:DCL.UpdateDispatcher
Assembly:UpdateEventHandler
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/UpdateEventHandler/UpdateDispatcher.cs
Covered lines:33
Uncovered lines:2
Coverable lines:35
Total lines:85
Line coverage:94.2% (33 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%220100%
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        {
 269211            public HashSet<Action> eventHashset = new HashSet<Action>();
 269212            public List<Action> eventList = new List<Action>();
 13
 14            public void Add(Action action)
 15            {
 320416                if ( eventHashset.Contains(action))
 017                    return;
 18
 320419                eventList.Add(action);
 320420                eventHashset.Add(action);
 320421            }
 22
 23            public void Remove(Action action)
 24            {
 2125                if ( !eventHashset.Contains(action))
 326                    return;
 27
 1828                eventList.Remove(action);
 1829                eventHashset.Remove(action);
 1830            }
 31
 32            public bool Contains(Action action)
 33            {
 034                return eventHashset.Contains(action);
 35            }
 36        }
 37
 67338        public Dictionary<IUpdateEventHandler.EventType, UpdateEventCollection> eventCollections = new Dictionary<IUpdat
 39
 40        void Awake()
 41        {
 67342            EnsureEventType(IUpdateEventHandler.EventType.Update);
 67343            EnsureEventType(IUpdateEventHandler.EventType.LateUpdate);
 67344            EnsureEventType(IUpdateEventHandler.EventType.FixedUpdate);
 67345            EnsureEventType(IUpdateEventHandler.EventType.OnGui);
 67346        }
 47
 48        void EnsureEventType( IUpdateEventHandler.EventType eventType )
 49        {
 269250            if ( !eventCollections.ContainsKey(eventType) )
 269251                eventCollections.Add(eventType, new UpdateEventCollection());
 269252        }
 53
 54        void Dispatch( IUpdateEventHandler.EventType eventType )
 55        {
 2313056            var list = eventCollections[eventType].eventList;
 2313057            int count = eventCollections[eventType].eventList.Count;
 58
 11701259            for ( int i = 0; i < count; i++ )
 60            {
 3537661                list[i].Invoke();
 62            }
 2313063        }
 64
 65        void Update()
 66        {
 762267            Dispatch(IUpdateEventHandler.EventType.Update);
 762268        }
 69
 70        void LateUpdate()
 71        {
 762272            Dispatch(IUpdateEventHandler.EventType.LateUpdate);
 762273        }
 74
 75        void FixedUpdate()
 76        {
 478277            Dispatch(IUpdateEventHandler.EventType.FixedUpdate);
 478278        }
 79
 80        void OnGUI()
 81        {
 310482            Dispatch(IUpdateEventHandler.EventType.OnGui);
 310483        }
 84    }
 85}