< Summary

Information
Class: Api.Controller.v1.EmployeeController
Assembly: Api
File(s): /home/runner/work/Northwind-Api/Northwind-Api/src/Api/Controller/v1/EmployeeController.cs
Line coverage
70%
Covered lines: 14
Uncovered lines: 6
Coverable lines: 20
Total lines: 46
Line coverage: 70%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
GetEmployees()100%11100%
GetEmployee()50%3245.45%

File(s)

/home/runner/work/Northwind-Api/Northwind-Api/src/Api/Controller/v1/EmployeeController.cs

#LineLine coverage
 1using Api.Extensions;
 2using Application.service;
 3using Application.Service;
 4using Infrastructure.Entity;
 5using Microsoft.AspNetCore.Mvc;
 6
 7namespace Api.Controller.v1;
 8
 9[ApiController]
 10[Route("api/[controller]/[action]")]
 11[ApiVersion("1")]
 12[Produces("application/json")]
 13public class EmployeeController : ControllerBase {
 14  private readonly ILogger<EmployeeController> _logger;
 15  private readonly EmployeeService _service;
 16
 417  public EmployeeController(ILogger<EmployeeController> logger, EmployeeService service) {
 218    _logger = logger;
 219    _service = service;
 220  }
 21
 22  [HttpGet]
 23  [ProducesResponseType(typeof(employee[]), StatusCodes.Status200OK)]
 124  public async Task<IActionResult> GetEmployees(CancellationToken ct) {
 125    var results = await _service.FindAll(ct);
 126    _logger.LogResults(typeof(employee), results);
 127    return Ok(results);
 128  }
 29
 30  [HttpGet]
 31  [ProducesResponseType(typeof(employee), StatusCodes.Status200OK)]
 32  [ProducesResponseType(StatusCodes.Status404NotFound)]
 133  public async Task<IActionResult> GetEmployee(short employeeId, CancellationToken ct) {
 134    var result = await _service.FindById(employeeId, ct);
 135    if (result is null) {
 036      _logger.LogInformation("Customer {CustomerId} not found", employeeId);
 37
 038      return NotFound(new ProblemDetails {
 039        Title = "Employee not found",
 040        Status = StatusCodes.Status404NotFound,
 041        Detail = $"Not employee with id „{employeeId}“ exists",
 042      });
 43    }
 144    return Ok(result);
 145  }
 46}