< Summary

Line coverage
100%
Covered lines: 76
Uncovered lines: 0
Coverable lines: 76
Total lines: 318
Line coverage: 100%
Branch coverage
100%
Covered branches: 14
Total branches: 14
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
File 1: .cctor()100%11100%
File 1: .cctor()100%11100%
File 1: .cctor()100%11100%
File 2: .cctor()100%11100%
File 2: get_EmptyErrors()100%11100%
File 3: get_Code()100%11100%
File 3: get_Message()100%11100%
File 3: get_Type()100%11100%
File 3: get_StackTrace()100%11100%
File 3: .ctor()100%11100%
File 3: .ctor(...)100%1010100%
File 3: .ctor(...)100%44100%
File 3: Create(...)100%11100%
File 3: WithStack(...)100%11100%
File 3: WithStack(...)100%11100%
File 3: Failure(...)100%11100%
File 3: Unexpected(...)100%11100%
File 3: Validation(...)100%11100%
File 3: Conflict(...)100%11100%
File 3: NotFound(...)100%11100%
File 3: Unauthorized(...)100%11100%
File 3: Forbidden(...)100%11100%
File 3: Exception(...)100%11100%
File 4: .cctor()100%11100%
File 4: .cctor()100%11100%
File 5: .cctor()100%11100%
File 6: .cctor()100%11100%
File 7: .cctor()100%11100%
File 8: .cctor()100%11100%
File 9: .cctor()100%11100%

File(s)

D:\Dotnet\Propuesta-trabajo\Enjoy Project\EnjoyApp\Enjoy\src\Enjoy.Domain\Jokes\Errors\JokeErrors.cs

#LineLine coverage
 1namespace Enjoy.Domain.Shared.Errors;
 2
 3public readonly partial record struct Error
 4{
 5    public static class Joke
 6    {
 17        public static readonly Error AuthorRequired = Validation("Joke.AuthorRequired", "The joke must have an author (A
 8
 19        public static readonly Func<string, Error> NotFound = id => Error.NotFound("Joke.NotFound", $"The joke with id {
 10
 111        public static readonly Error TopicIdRequired = Validation("Joke.TopicIdRequired", "The topic id cannot be empty 
 12    }
 13
 14    public static class JokeText
 15    {
 116        public static readonly Error IsNullOrEmpty = Validation("JokeText.IsNullOrEmpty", "The joke text cannot be empty
 17
 318        public static readonly Func<int, Error> TooLong = length => Validation("JokeText.TooLong", $"The joke text canno
 19    }
 20
 21    public static class Origin
 22    {
 123        public static readonly Error IsNullOrEmpty = Validation("Origin.IsNullOrEmpty", "The joke origin cannot be empty
 24
 125        public static readonly Error Invalid = Validation("Origin.Invalid", "The specified origin is not valid.");
 26    }
 27}

D:\Dotnet\Propuesta-trabajo\Enjoy Project\EnjoyApp\Enjoy\src\Enjoy.Domain\Shared\Errors\Error.Common.cs

#LineLine coverage
 1namespace Enjoy.Domain.Shared.Errors;
 2
 3/// <summary>
 4/// Define errores predefinidos comunes utilizados en toda la aplicación.
 5/// </summary>
 6public readonly partial record struct Error
 7{
 8    /// <summary>
 9    /// Representa la ausencia de error.
 10    /// </summary>
 111    public static readonly Error None = Create(string.Empty, string.Empty, ErrorType.None);
 12
 13    /// <summary>
 14    /// Representa un error cuando el valor especificado es nulo.
 15    /// </summary>
 116    public static readonly Error NullValue = Validation("Error.NullValue", "The specified result value is null.");
 17
 18    /// <summary>
 19    /// Representa un error desconocido.
 20    /// </summary>
 121    public static readonly Error Unknown = Unexpected("Error.Unknown", "An unknown error occurred.");
 22
 23    /// <summary>
 24    /// Representa una colección de errores vacía.
 25    /// </summary>
 46726    public static ICollection<Error> EmptyErrors { get; } = [];
 27}

D:\Dotnet\Propuesta-trabajo\Enjoy Project\EnjoyApp\Enjoy\src\Enjoy.Domain\Shared\Errors\Error.cs

#LineLine coverage
 1using Enjoy.Domain.Shared.Extensions;
 2
 3namespace Enjoy.Domain.Shared.Errors;
 4
 5/// <summary>
 6/// Representa un error con un código y un mensaje descriptivo.
 7/// </summary>
 8public readonly partial record struct Error
 9{
 10    /// <summary>
 11    /// Código del error.
 12    /// </summary>
 12213    public string Code { get; init; }
 14
 15    /// <summary>
 16    /// Mensaje descriptivo del error.
 17    /// </summary>
 11118    public string Message { get; init; }
 19
 20    /// <summary>
 21    /// Tipo del error.
 22    /// </summary>
 12223    public ErrorType Type { get; init; }
 24
 25    /// <summary>
 26    /// Una colección de errores adicionales que proporcionan más contexto sobre el error principal.
 27    /// </summary>
 10428    public IReadOnlyCollection<Error>? StackTrace { get; init; }
 29
 30    /// <summary>
 31    /// Constructor por defecto que lanza una excepción.
 32    /// Use el método estático <see cref="Create"/> para instanciar <see cref="Error"/>.
 33    /// </summary>
 34    /// <exception cref="InvalidOperationException">Se lanza siempre para indicar que este constructor no debe ser usado
 35    public Error()
 136    {
 137        throw new InvalidOperationException("Use the static Create method to instantiate Error");
 38    }
 39
 40    /// <summary>
 41    /// Inicializa una nueva instancia de la estructura <see cref="Error"/> con el código, mensaje y tipo especificados.
 42    /// </summary>
 43    /// <param name="code">El código del error.</param>
 44    /// <param name="message">El mensaje descriptivo del error.</param>
 45    /// <param name="type">El tipo del error.</param>
 46    /// <exception cref="ArgumentNullException">Se lanza cuando el código o el mensaje son nulos.</exception>
 47    private Error(string? code, string? message, ErrorType type, IReadOnlyCollection<Error>? stack = null)
 10248    {
 10249        if (code is null)
 150        {
 151            throw new ArgumentNullException(nameof(code), "Error code cannot be null.");
 52        }
 53
 10154        if (message is null)
 155        {
 156            throw new ArgumentNullException(nameof(message), "Error message cannot be null.");
 57        }
 58
 10059        Code = !string.IsNullOrWhiteSpace(code) ? code : string.Empty;
 10060        Message = !string.IsNullOrWhiteSpace(message) ? message : string.Empty;
 10061        Type = type;
 10062        StackTrace = stack ?? [];
 10063    }
 64
 65    /// <summary>
 66    /// Inicializa una nueva instancia de la estructura <see cref="Error"/> con una pila de errores.
 67    /// </summary>
 68    /// <param name="stack"></param>
 69    private Error(IReadOnlyCollection<Error>? stack)
 370    {
 371        if (stack is null || stack.IsEmptyReadOnly())
 272        {
 273            throw new ArgumentNullException(nameof(stack), "Error stack cannot be null or empty.");
 74        }
 75
 176        Code = stack.First().Code;
 177        Message = stack.First().Message;
 178        Type = stack.First().Type;
 179        StackTrace = stack;
 180    }
 81
 82    /// <summary>
 83    /// Crea una nueva instancia de la estructura <see cref="Error"/> con el código, mensaje y tipo especificados.
 84    /// </summary>
 85    /// <param name="code">El código del error.</param>
 86    /// <param name="message">El mensaje descriptivo del error.</param>
 87    /// <param name="type">El tipo del error.</param>
 88    /// <returns>Una nueva instancia de la estructura <see cref="Error"/>.</returns>
 689    public static Error Create(string? code, string? message, ErrorType type, IReadOnlyCollection<Error>? stack = null) 
 90
 91    /// <summary>
 92    /// Crea una nueva instancia de la estructura <see cref="Error"/> con una pila de errores.
 93    /// </summary>
 94    /// <param name="error">El error existente.</param>
 95    /// <param name="stack">La pila de errores asociados opcional.</param>
 96    /// <returns>Una nueva instancia de la estructura <see cref="Error"/> con la pila de errores.</returns>
 197    public static Error WithStack(Error error, IReadOnlyCollection<Error>? stack) => new(error.Code, error.Message, erro
 98
 99    /// <summary>
 100    /// Crea una nueva instancia de la estructura <see cref="Error"/> con una pila de errores.
 101    /// </summary>
 102    /// <param name="errors">Coleccón de errores.</param>
 103    /// <returns>Una nueva instancia de la estructura <see cref="Error"/> con la pila de errores.</returns>
 3104    public static Error WithStack(IReadOnlyCollection<Error>? errors) => new(errors);
 105
 106    /// <summary>
 107    /// Crea una nueva instancia de la estructura <see cref="Error"/> de tipo <see cref="ErrorType.Failure"/> con el cód
 108    /// </summary>
 109    /// <param name="code">El código del error.</param>
 110    /// <param name="message">El mensaje descriptivo del error.</param>
 111    /// <returns>Una nueva instancia de la estructura <see cref="Error"/>.</returns>
 2112    public static Error Failure(string? code, string? message, IReadOnlyCollection<Error>? stack = null) => new(code, me
 113
 114    /// <summary>
 115    /// Crea una nueva instancia de la estructura <see cref="Error"/> de tipo <see cref="ErrorType.Unexpected"/> con el 
 116    /// </summary>
 117    /// <param name="code">El código del error.</param>
 118    /// <param name="message">El mensaje descriptivo del error.</param>
 119    /// <returns>Una nueva instancia de la estructura <see cref="Error"/>.</returns>
 2120    public static Error Unexpected(string? code, string? message, IReadOnlyCollection<Error>? stack = null) => new(code,
 121
 122    /// <summary>
 123    /// Crea una nueva instancia de la estructura <see cref="Error"/> de tipo <see cref="ErrorType.Validation"/> con el 
 124    /// </summary>
 125    /// <param name="code">El código del error.</param>
 126    /// <param name="message">El mensaje descriptivo del error.</param>
 127    /// <returns>Una nueva instancia de la estructura <see cref="Error"/>.</returns>
 77128    public static Error Validation(string? code, string? message, IReadOnlyCollection<Error>? stack = null) => new(code,
 129
 130    /// <summary>
 131    /// Crea una nueva instancia de la estructura <see cref="Error"/> de tipo <see cref="ErrorType.Conflict"/> con el có
 132    /// </summary>
 133    /// <param name="code">El código del error.</param>
 134    /// <param name="message">El mensaje descriptivo del error.</param>
 135    /// <returns>Una nueva instancia de la estructura <see cref="Error"/>.</returns>
 2136    public static Error Conflict(string? code, string? message, IReadOnlyCollection<Error>? stack = null) => new(code, m
 137
 138    /// <summary>
 139    /// Crea una nueva instancia de la estructura <see cref="Error"/> de tipo <see cref="ErrorType.NotFound"/> con el có
 140    /// </summary>
 141    /// <param name="code">El código del error.</param>
 142    /// <param name="message">El mensaje descriptivo del error.</param>
 143    /// <returns>Una nueva instancia de la estructura <see cref="Error"/>.</returns>
 5144    public static Error NotFound(string? code, string? message, IReadOnlyCollection<Error>? stack = null) => new(code, m
 145
 146    /// <summary>
 147    /// Crea una nueva instancia de la estructura <see cref="Error"/> de tipo <see cref="ErrorType.Unauthorized"/> con e
 148    /// </summary>
 149    /// <param name="code">El código del error.</param>
 150    /// <param name="message">El mensaje descriptivo del error.</param>
 151    /// <returns>Una nueva instancia de la estructura <see cref="Error"/>.</returns>
 2152    public static Error Unauthorized(string? code, string? message, IReadOnlyCollection<Error>? stack = null) => new(cod
 153
 154    /// <summary>
 155    /// Crea una nueva instancia de la estructura <see cref="Error"/> de tipo <see cref="ErrorType.Forbidden"/> con el c
 156    /// </summary>
 157    /// <param name="code">El código del error.</param>
 158    /// <param name="message">El mensaje descriptivo del error.</param>
 159    /// <returns>Una nueva instancia de la estructura <see cref="Error"/>.</returns>
 1160    public static Error Forbidden(string? code, string? message, IReadOnlyCollection<Error>? stack = null) => new(code, 
 161
 162    /// <summary>
 163    /// Crea una nueva instancia de la estructura <see cref="Error"/> de tipo <see cref="ErrorType.Exception"/> con el c
 164    /// </summary>
 165    /// <param name="code">El código del error.</param>
 166    /// <param name="message">El mensaje descriptivo del error.</param>
 167    /// <returns>Una nueva instancia de la estructura <see cref="Error"/>.</returns>
 4168    public static Error Exception(string? code, string? message, IReadOnlyCollection<Error>? stack = null) => new(code, 
 169}

D:\Dotnet\Propuesta-trabajo\Enjoy Project\EnjoyApp\Enjoy\src\Enjoy.Domain\Topics\Errors\TopicErrors.cs

#LineLine coverage
 1namespace Enjoy.Domain.Shared.Errors;
 2
 3public readonly partial record struct Error
 4{
 5    public static class Topic
 6    {
 17        public static readonly Func<string, Error> NotFound =
 28            id => Error.NotFound("Topic.NotFound", $"The topic with id {id} was not found.");
 9    }
 10
 11    public static class TopicName
 12    {
 113        public static readonly Error IsNullOrEmpty =
 114            Validation("TopicName.IsNullOrEmpty", "The topic name cannot be empty.");
 15
 116        public static readonly Func<int, Error> TooLong =
 317            length => Validation("TopicName.TooLong", $"The topic name cannot exceed {length} characters.");
 18
 119        public static readonly Func<int, Error> TooShort =
 520            length => Validation("TopicName.TooShort", $"The topic name must be at least {length} characters.");
 21    }
 22}

D:\Dotnet\Propuesta-trabajo\Enjoy Project\EnjoyApp\Enjoy\src\Enjoy.Domain\Users\Errors\EmailErrors.cs

#LineLine coverage
 1namespace Enjoy.Domain.Shared.Errors;
 2
 3public readonly partial record struct Error
 4{
 5    public static class Email
 6    {
 17        public static readonly Error IsNullOrEmpty = Validation("Email.IsNullOrEmpty", "The email cannot be empty.");
 8
 19        public static readonly Error InvalidFormat = Validation("Email.InvalidFormat", "The email does not meet the form
 10
 311        public static readonly Func<int, Error> TooLong = length => Validation("Email.TooLong", $"The email cannot excee
 12
 513        public static readonly Func<int, Error> TooShort = length => Validation("Email.TooShort", $"The email must be at
 14    }
 15}

D:\Dotnet\Propuesta-trabajo\Enjoy Project\EnjoyApp\Enjoy\src\Enjoy.Domain\Users\Errors\NameErrors.cs

#LineLine coverage
 1namespace Enjoy.Domain.Shared.Errors;
 2
 3public readonly partial record struct Error
 4{
 5    public static class Name
 6    {
 17        public static readonly Error IsNullOrEmpty = Validation("FirstName.IsNullOrEmpty", "The first name cannot be emp
 8
 19        public static readonly Error InvalidFormat = Validation("FirstName.InvalidFormat", "First name format is invalid
 10
 311        public static readonly Func<int, Error> TooLong = length => Validation("FirstName.TooLong", $"First name cannot 
 12
 413        public static readonly Func<int, Error> TooShort = length => Validation("FirstName.TooShort", $"First name must 
 14    }
 15}

D:\Dotnet\Propuesta-trabajo\Enjoy Project\EnjoyApp\Enjoy\src\Enjoy.Domain\Users\Errors\PasswordHashErrors.cs

#LineLine coverage
 1namespace Enjoy.Domain.Shared.Errors;
 2
 3public readonly partial record struct Error
 4{
 5    public static class PasswordHash
 6    {
 17        public static readonly Error IsNullOrEmpty = Validation("PasswordHash.IsNullOrEmpty", "The password hash cannot 
 8
 39        public static readonly Func<int, Error> TooLong = length => Validation("PasswordHash.TooLong", $"The password ha
 10
 311        public static readonly Func<int, Error> TooShort = length => Validation("PasswordHash.TooShort", $"The password 
 12    }
 13}

D:\Dotnet\Propuesta-trabajo\Enjoy Project\EnjoyApp\Enjoy\src\Enjoy.Domain\Users\Errors\RoleErrors.cs

#LineLine coverage
 1namespace Enjoy.Domain.Shared.Errors;
 2
 3public readonly partial record struct Error
 4{
 5    public static class Role
 6    {
 17        public static readonly Error IsNullOrEmpty = Validation("Role.IsNullOrEmpty", "The role cannot be empty.");
 8
 19        public static readonly Error Invalid = Validation("Role.Invalid", "The specified role is not valid. Valid values
 10    }
 11}

D:\Dotnet\Propuesta-trabajo\Enjoy Project\EnjoyApp\Enjoy\src\Enjoy.Domain\Users\Errors\UserErrors.cs

#LineLine coverage
 1namespace Enjoy.Domain.Shared.Errors;
 2
 3public readonly partial record struct Error
 4{
 5    public static class User
 6    {
 17        public static readonly Error IsNull = Validation("User.IsNull", "The user cannot be null.");
 8
 19        public static readonly Error EmailAlreadyInUse = Conflict("User.EmailAlreadyInUse", "The specified email is alre
 10
 211        public static readonly Func<Guid, Error> NotFound = id => Error.NotFound("User.NotFound", $"The user with the id
 12
 213        public static readonly Func<string, Error> EmailNotExist = email => Error.NotFound("User.EmailNotExist", $"The e
 14
 115        public static readonly Error InvalidCredentials = Unauthorized("User.InvalidCredentials", "The specified credent
 16
 117        public static readonly Error NoUsersFound = Error.NotFound("User.NoUsersFound", "No users were found.");
 18    }
 19}

Methods/Properties

.cctor()
.cctor()
.cctor()
.cctor()
get_EmptyErrors()
get_Code()
get_Message()
get_Type()
get_StackTrace()
.ctor()
.ctor(System.String,System.String,Enjoy.Domain.Shared.Errors.ErrorType,System.Collections.Generic.IReadOnlyCollection`1<Enjoy.Domain.Shared.Errors.Error>)
.ctor(System.Collections.Generic.IReadOnlyCollection`1<Enjoy.Domain.Shared.Errors.Error>)
Create(System.String,System.String,Enjoy.Domain.Shared.Errors.ErrorType,System.Collections.Generic.IReadOnlyCollection`1<Enjoy.Domain.Shared.Errors.Error>)
WithStack(Enjoy.Domain.Shared.Errors.Error,System.Collections.Generic.IReadOnlyCollection`1<Enjoy.Domain.Shared.Errors.Error>)
WithStack(System.Collections.Generic.IReadOnlyCollection`1<Enjoy.Domain.Shared.Errors.Error>)
Failure(System.String,System.String,System.Collections.Generic.IReadOnlyCollection`1<Enjoy.Domain.Shared.Errors.Error>)
Unexpected(System.String,System.String,System.Collections.Generic.IReadOnlyCollection`1<Enjoy.Domain.Shared.Errors.Error>)
Validation(System.String,System.String,System.Collections.Generic.IReadOnlyCollection`1<Enjoy.Domain.Shared.Errors.Error>)
Conflict(System.String,System.String,System.Collections.Generic.IReadOnlyCollection`1<Enjoy.Domain.Shared.Errors.Error>)
NotFound(System.String,System.String,System.Collections.Generic.IReadOnlyCollection`1<Enjoy.Domain.Shared.Errors.Error>)
Unauthorized(System.String,System.String,System.Collections.Generic.IReadOnlyCollection`1<Enjoy.Domain.Shared.Errors.Error>)
Forbidden(System.String,System.String,System.Collections.Generic.IReadOnlyCollection`1<Enjoy.Domain.Shared.Errors.Error>)
Exception(System.String,System.String,System.Collections.Generic.IReadOnlyCollection`1<Enjoy.Domain.Shared.Errors.Error>)
.cctor()
.cctor()
.cctor()
.cctor()
.cctor()
.cctor()
.cctor()