< Summary

Class:DCL.UpdateDispatcher
Assembly:UpdateEventHandler
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/UpdateEventHandler/UpdateDispatcher.cs
Covered lines:35
Uncovered lines:3
Coverable lines:38
Total lines:91
Line coverage:92.1% (35 of 38)
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%
OnDestroy()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        {
 275511            public HashSet<Action> eventHashset = new HashSet<Action>();
 275512            public List<Action> eventList = new List<Action>();
 13
 14            public void Add(Action action)
 15            {
 218616                if ( eventHashset.Contains(action))
 017                    return;
 18
 218619                eventList.Add(action);
 218620                eventHashset.Add(action);
 218621            }
 22
 23            public void Remove(Action action)
 24            {
 20725                if ( !eventHashset.Contains(action))
 026                    return;
 27
 20728                eventList.Remove(action);
 20729                eventHashset.Remove(action);
 20730            }
 31
 32            public bool Contains(Action action)
 33            {
 034                return eventHashset.Contains(action);
 35            }
 36        }
 37
 55138        public Dictionary<IUpdateEventHandler.EventType, UpdateEventCollection> eventCollections = new Dictionary<IUpdat
 39
 40        void Awake()
 41        {
 55142            EnsureEventType(IUpdateEventHandler.EventType.Update);
 55143            EnsureEventType(IUpdateEventHandler.EventType.LateUpdate);
 55144            EnsureEventType(IUpdateEventHandler.EventType.FixedUpdate);
 55145            EnsureEventType(IUpdateEventHandler.EventType.OnGui);
 55146            EnsureEventType(IUpdateEventHandler.EventType.OnDestroy);
 55147        }
 48
 49        void EnsureEventType( IUpdateEventHandler.EventType eventType )
 50        {
 275551            if ( !eventCollections.ContainsKey(eventType) )
 275552                eventCollections.Add(eventType, new UpdateEventCollection());
 275553        }
 54
 55        void Dispatch( IUpdateEventHandler.EventType eventType )
 56        {
 9287457            var list = eventCollections[eventType].eventList;
 9287458            int count = eventCollections[eventType].eventList.Count;
 59
 47124860            for ( int i = 0; i < count; i++ )
 61            {
 14275062                list[i].Invoke();
 63            }
 9287464        }
 65
 66        void Update()
 67        {
 4416368            Dispatch(IUpdateEventHandler.EventType.Update);
 4416369        }
 70
 71        void LateUpdate()
 72        {
 4416373            Dispatch(IUpdateEventHandler.EventType.LateUpdate);
 4416374        }
 75
 76        void FixedUpdate()
 77        {
 265178            Dispatch(IUpdateEventHandler.EventType.FixedUpdate);
 265179        }
 80
 81        void OnGUI()
 82        {
 134683            Dispatch(IUpdateEventHandler.EventType.OnGui);
 134684        }
 85
 86        private void OnDestroy()
 87        {
 55188            Dispatch(IUpdateEventHandler.EventType.OnDestroy);
 55189        }
 90    }
 91}