< Summary

Class:DCL.UpdateDispatcher
Assembly:UpdateController
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        {
 276811            public HashSet<Action> eventHashset = new HashSet<Action>();
 276812            public List<Action> eventList = new List<Action>();
 13
 14            public void Add(Action action)
 15            {
 200316                if ( eventHashset.Contains(action))
 017                    return;
 18
 200319                eventList.Add(action);
 200320                eventHashset.Add(action);
 200321            }
 22
 23            public void Remove(Action action)
 24            {
 200325                if ( !eventHashset.Contains(action))
 326                    return;
 27
 200028                eventList.Remove(action);
 200029                eventHashset.Remove(action);
 200030            }
 31
 32            public bool Contains(Action action)
 33            {
 034                return eventHashset.Contains(action);
 35            }
 36        }
 37
 69238        public Dictionary<IUpdateEventHandler.EventType, UpdateEventCollection> eventCollections = new Dictionary<IUpdat
 39
 40        void Awake()
 41        {
 69242            EnsureEventType(IUpdateEventHandler.EventType.Update);
 69243            EnsureEventType(IUpdateEventHandler.EventType.LateUpdate);
 69244            EnsureEventType(IUpdateEventHandler.EventType.FixedUpdate);
 69245            EnsureEventType(IUpdateEventHandler.EventType.OnGui);
 69246        }
 47
 48        void EnsureEventType( IUpdateEventHandler.EventType eventType )
 49        {
 276850            if ( !eventCollections.ContainsKey(eventType) )
 276851                eventCollections.Add(eventType, new UpdateEventCollection());
 276852        }
 53
 54        void Dispatch( IUpdateEventHandler.EventType eventType )
 55        {
 3459756            var list = eventCollections[eventType].eventList;
 3459757            int count = eventCollections[eventType].eventList.Count;
 58
 14132059            for ( int i = 0; i < count; i++ )
 60            {
 3606361                list[i].Invoke();
 62            }
 3459763        }
 64
 65        void Update()
 66        {
 1246367            Dispatch(IUpdateEventHandler.EventType.Update);
 1246368        }
 69
 70        void LateUpdate()
 71        {
 1246372            Dispatch(IUpdateEventHandler.EventType.LateUpdate);
 1246373        }
 74
 75        void FixedUpdate()
 76        {
 468577            Dispatch(IUpdateEventHandler.EventType.FixedUpdate);
 468578        }
 79
 80        void OnGUI()
 81        {
 498682            Dispatch(IUpdateEventHandler.EventType.OnGui);
 498683        }
 84    }
 85}