< Summary

Class:SVETA.Api.Data.Domain.ConfigurationsSettings
Assembly:SVETA.Api
File(s):/opt/dev/sveta_api_build/SVETA.Api/Data/Domain/ConfigurationsSettings.cs
Covered lines:0
Uncovered lines:14
Coverable lines:14
Total lines:29
Line coverage:0% (0 of 14)
Covered branches:0
Total branches:10
Branch coverage:0% (0 of 10)

Metrics

MethodLine coverage Branch coverage
get_AppConfs()0%100%
GetConfValue(...)0%0%
SetConfValue(...)0%0%

File(s)

/opt/dev/sveta_api_build/SVETA.Api/Data/Domain/ConfigurationsSettings.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using SVETA.Api.Data.DTO;
 5using System.Threading.Tasks;
 6using WinSolutions.Sveta.Server.Data.DataModel.Entities;
 7
 8namespace SVETA.Api.Data.Domain
 9{
 10    public class ConfigurationsSettings
 11    {
 012        public ICollection<ConfigurationResponseDTO> AppConfs { get; set; } = new List<ConfigurationResponseDTO>();
 13        public string GetConfValue(string section, string key)
 014        {
 015            var value = AppConfs.FirstOrDefault(x => x.Section == section && x.Key == key)?.Value;
 016            if (string.IsNullOrWhiteSpace(value))
 017                throw new ArgumentException($"Не указан ключ {key} для секции {section}");
 018            return value;
 019        }
 20        public void SetConfValue(string section, string key, string value)
 021        {
 022            if (!AppConfs.Any(x => x.Section == section && x.Key == key))
 023                throw new ArgumentException($"Не найдено записей конфигурации с ключом {key} и секцией {section}");
 024            if (string.IsNullOrWhiteSpace(value))
 025                throw new ArgumentException($"Не указано значение для ключа {key}");
 026            AppConfs.FirstOrDefault(x => x.Section == section && x.Key == key).Value = value;
 027        }
 28    }
 29}