< Summary

Class:DCL.SettingsCommon.ProxySettingsRepository[T]
Assembly:Settings
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Settings/ProxySettingsRepository.cs
Covered lines:11
Uncovered lines:2
Coverable lines:13
Total lines:41
Line coverage:84.6% (11 of 13)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
add_OnChanged(...)0%110100%
remove_OnChanged(...)0%110100%
ProxySettingsRepository(...)0%110100%
Apply(...)0%110100%
Reset()0%110100%
Save()0%110100%
HasAnyData()0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/Settings/ProxySettingsRepository.cs

#LineLine coverage
 1using System;
 2
 3namespace DCL.SettingsCommon
 4{
 5    public class ProxySettingsRepository<T> : ISettingsRepository<T> where T : struct
 6    {
 7        private readonly ISettingsRepository<T> latestRepository;
 8        private readonly ISettingsRepository<T> recoveryRepository;
 9
 10        public event Action<T> OnChanged
 11        {
 32712            add => latestRepository.OnChanged += value;
 14213            remove => latestRepository.OnChanged -= value;
 14        }
 15
 16        public T Data
 17        {
 18            get
 19            {
 31020                if (!latestRepository.HasAnyData() && recoveryRepository.HasAnyData())
 021                    latestRepository.Apply(recoveryRepository.Data);
 31022                return latestRepository.Data;
 23            }
 24        }
 25
 192026        public ProxySettingsRepository(ISettingsRepository<T> latestRepository,
 27            ISettingsRepository<T> recoveryRepository)
 28        {
 192029            this.latestRepository = latestRepository;
 192030            this.recoveryRepository = recoveryRepository;
 192031        }
 32
 3633        public void Apply(T settings) => latestRepository.Apply(settings);
 34
 7535        public void Reset() => latestRepository.Reset();
 36
 337        public void Save() => latestRepository.Save();
 38
 039        public bool HasAnyData() => latestRepository.HasAnyData();
 40    }
 41}