< Summary

Information
Class: ConsoleApp1.StoredProcedureTypeExtensions
Assembly: TreeGrouping.Application
File(s): /home/runner/work/Studio2Prod/Studio2Prod/TreeGrouping.Application/DbService/Types/StoredProcedureTypeExtensions.cs
Line coverage
100%
Covered lines: 57
Uncovered lines: 0
Coverable lines: 57
Total lines: 110
Line coverage: 100%
Branch coverage
100%
Covered branches: 70
Total branches: 70
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetProcedureName(...)100%1919100%
GetParameter(...)100%5151100%

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/TreeGrouping.Application/DbService/Types/StoredProcedureTypeExtensions.cs

#LineLine coverage
 1namespace ConsoleApp1;
 2
 3public static class StoredProcedureTypeExtensions
 4{
 5    public static string GetProcedureName(this StoredProcedureType type)
 6    {
 197        return type switch
 198        {
 19            StoredProcedureType.GetVolnaCategories => "GetVolnaCategories",
 110            StoredProcedureType.GetOzonCategories => "GetOzonCategories",
 111            StoredProcedureType.GetCtCategories => "GetCtCategories",
 112            StoredProcedureType.GetICGroups => "GetICGroups",
 113            StoredProcedureType.SearchVolnaCategoryByName => "SearchVolnaCategoryByName",
 114            StoredProcedureType.SearchOzonCategoryByName => "SearchOzonCategoryByName",
 115            StoredProcedureType.SearchCtCategoryByName => "SearchCtCategoryByName",
 116            StoredProcedureType.SearchVolnaCategoryById => "SearchVolnaCategoryById",
 117            StoredProcedureType.SearchOzonCategoryById => "SearchOzonCategoryById",
 118            StoredProcedureType.SearchCtCategoryById => "SearchCtCategoryById",
 119            StoredProcedureType.AddCategoryLink => "AddCategoryLink",
 120            StoredProcedureType.DeleteCategoryLink => "DeleteCategoryLinkById",
 121            StoredProcedureType.GetCatTreeCategories => "GetCatTreeCategories",
 122            StoredProcedureType.SearchCatTreeCategoryById => "SearchCatTreeCategoryById",
 123            StoredProcedureType.SearchICGroupById => "SearchICGroupById",
 124            StoredProcedureType.InsertUnifiedCategoryIfNotExists => "sp_InsertUnifiedCategoryIfNotExists",
 125            StoredProcedureType.DeleteUnifiedCategoryByIcId => "DeleteUnifiedCategoryByIcId",
 126            StoredProcedureType.AddCategoryTranslations => "AddCategoryTranslations",
 127            _ => throw new ArgumentException("Unknown procedure type")
 1928        };
 29    }
 30    public static Dictionary<string, object> GetParameter(this StoredProcedureType type, object parameter)
 31    {
 1532        var paramDict = new Dictionary<string, object>();
 33
 1534        if (parameter is not null)
 35        {
 36            switch (type)
 37            {
 38                case StoredProcedureType.SearchVolnaCategoryByName:
 39                case StoredProcedureType.SearchOzonCategoryByName:
 40                case StoredProcedureType.SearchCtCategoryByName:
 341                    if (parameter is string searchName)
 42                    {
 343                        paramDict["searchName"] = searchName;
 44                    }
 345                    break;
 46
 47                case StoredProcedureType.SearchCtCategoryById:
 48                case StoredProcedureType.SearchVolnaCategoryById:
 49                case StoredProcedureType.SearchOzonCategoryById:
 450                    if (parameter is int searchId)
 51                    {
 352                        paramDict["categoryId"] = searchId;
 53                    }
 354                    break;
 55
 56                case StoredProcedureType.AddCategoryLink:
 157                    if (parameter is (int ctCategoryId, int linkCategoryId, string linkTypeName))
 58                    {
 159                        paramDict["ct_category_id"] = ctCategoryId;
 160                        paramDict["link_category_id"] = linkCategoryId;
 161                        paramDict["link_type_name"] = linkTypeName;
 62                    }
 163                    break;
 64                case StoredProcedureType.DeleteCategoryLink:
 165                    if (parameter is int categoryLinkId)
 66                    {
 167                        paramDict["CategoryLinkId"] = categoryLinkId;
 68                    }
 169                    break;
 70                case StoredProcedureType.SearchCatTreeCategoryById:
 171                    if (parameter is int catTreeId)
 72                    {
 173                        paramDict["categoryId"] = catTreeId;
 74                    }
 175                    break;
 76                case StoredProcedureType.SearchICGroupById:
 177                    if (parameter is int groupId)
 78                    {
 179                        paramDict["groupId"] = groupId;
 80                    }
 181                    break;
 82                case StoredProcedureType.InsertUnifiedCategoryIfNotExists:
 183                    if (parameter is ValueTuple<int?, int?, int?> tuple)
 84                    {
 185                        paramDict["ozon_id"] = tuple.Item1;
 186                        paramDict["volna_id"] = tuple.Item2;
 187                        paramDict["ic_id"] = tuple.Item3;
 88                    }
 189                    break;
 90                case StoredProcedureType.DeleteUnifiedCategoryByIcId:
 191                    if (parameter is int icId)
 92                    {
 193                        paramDict["IcId"] = icId;
 94                    }
 195                    break;
 96                case StoredProcedureType.AddCategoryTranslations:
 197                    if (parameter is (int categoryId, string linkType, string translation))
 98                    {
 199                        paramDict["category_id"] = categoryId;
 1100                        paramDict["link_type_name"] = linkType;
 1101                        paramDict["translation"] = translation;
 102                    }
 103                    break;
 104
 105            }
 106        }
 107
 15108        return paramDict;
 109    }
 110}