< Summary

Class:MUNity.Schema.Extensions.ResponseBuilderExtensions
Assembly:MUNity.Schema
File(s):C:\Users\aeuke\source\repos\PeerConradi\munity\src\MUNitySchema\Extensions\ResponseBuilderExtensions.cs
Covered lines:0
Uncovered lines:45
Coverable lines:45
Total lines:69
Line coverage:0% (0 of 45)
Covered branches:0
Total branches:0
Covered methods:0
Total methods:7
Method coverage:0% (0 of 7)

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
AddNoPermissionError(...)100%10%
AddInvalidDataError(...)100%10%
AddMissingDataError(...)100%10%
AddNotFoundError(...)100%10%
AddConferenceNotFoundError(...)100%10%
AddCommitteeNotFoundError(...)100%10%
AddWarning(...)100%10%

File(s)

C:\Users\aeuke\source\repos\PeerConradi\munity\src\MUNitySchema\Extensions\ResponseBuilderExtensions.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Text;
 4
 5namespace MUNity.Schema.Extensions
 6{
 7    public static class ResponseBuilderExtensions
 8    {
 9        public static void AddNoPermissionError(this AbstractResponse response, string description = "")
 010        {
 011            response.HasError = true;
 012            response.Errors.Add(new ResponseError()
 013            {
 014                ErrorType = ErrorTypes.NoPermission,
 015                Description = description
 016            });
 017        }
 18
 19        public static void AddInvalidDataError(this AbstractResponse response, string description, string parameter = ""
 020        {
 021            response.HasError = true;
 022            response.Errors.Add(new ResponseError()
 023            {
 024                ErrorType = ErrorTypes.InvalidData,
 025                Description = description,
 026                ParameterName = parameter
 027            });
 028        }
 29
 30        public static void AddMissingDataError(this AbstractResponse response, string description, string parameter)
 031        {
 032            response.HasError = true;
 033            response.Errors.Add(new ResponseError()
 034            {
 035                ErrorType = ErrorTypes.MissingData,
 036                Description = description,
 037                ParameterName = parameter
 038            });
 039        }
 40
 41        public static void AddNotFoundError(this AbstractResponse response, string parameterName)
 042        {
 043            response.HasError = true;
 044            response.Errors.Add(new ResponseError()
 045            {
 046                ErrorType = ErrorTypes.InvalidData,
 047                Description = $"The data for {parameterName} was not found.",
 048                ParameterName = parameterName
 049            });
 050        }
 51
 52        public static void AddConferenceNotFoundError(this AbstractResponse response) =>
 053            response.AddInvalidDataError("The needed Conference was not found");
 54
 55        public static void AddCommitteeNotFoundError(this AbstractResponse response) =>
 056            response.AddInvalidDataError("The needed Committee was not found");
 57
 58
 59        public static void AddWarning(this AbstractResponse response, string description, string parameter = null)
 060        {
 061            response.Errors.Add(new ResponseError()
 062            {
 063                ErrorType = ErrorTypes.MissingData,
 064                Description = description,
 065                ParameterName = parameter
 066            });
 067        }
 68    }
 69}