< Summary

Information
Class: LGDXRobotCloud.Data.Models.DTOs.V1.Commands.LgdxRoleUpdateDto
Assembly: LGDXRobotCloud.Data
File(s): /builds/yukaitung/lgdxrobot2-cloud/LGDXRobotCloud.Data/Models/DTOs/V1/Commands/LgdxRoleUpdateDto.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 14
Coverable lines: 14
Total lines: 40
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Name()100%210%
get_Description()100%210%
get_Scopes()100%210%
Validate()0%2040%

File(s)

/builds/yukaitung/lgdxrobot2-cloud/LGDXRobotCloud.Data/Models/DTOs/V1/Commands/LgdxRoleUpdateDto.cs

#LineLine coverage
 1using System.ComponentModel.DataAnnotations;
 2using LGDXRobotCloud.Data.Models.Business.Administration;
 3
 4namespace LGDXRobotCloud.Data.Models.DTOs.V1.Commands;
 5
 6public record LgdxRoleUpdateDto : IValidatableObject
 7{
 8  [Required (ErrorMessage = "Please enter a name.")]
 09  public required string Name { get; set; }
 10
 011  public string? Description { get; set; }
 12
 013  public IEnumerable<string> Scopes { get; set; } = []; // Empty scope is allowed
 14
 15  public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
 016  {
 017    int i = 0;
 018    foreach (var scope in Scopes)
 019    {
 020      if (string.IsNullOrWhiteSpace(scope))
 021      {
 022        yield return new ValidationResult($"Scope is required.", [nameof(Scopes), $"{nameof(Scopes)}-{i}"]);
 023      }
 024      i++;
 025    }
 026  }
 27}
 28
 29public static class LgdxRoleUpdateDtoExtensions
 30{
 31  public static LgdxRoleUpdateBusinessModel ToBusinessModel(this LgdxRoleUpdateDto model)
 32  {
 33    return new LgdxRoleUpdateBusinessModel
 34    {
 35      Name = model.Name,
 36      Description = model.Description,
 37      Scopes = model.Scopes,
 38    };
 39  }
 40}