< Summary

Information
Class: Api.Controller.v1.CustomerController
Assembly: Api
File(s): /home/runner/work/Northwind-Api/Northwind-Api/src/Api/Controller/v1/CustomerController.cs
Line coverage
70%
Covered lines: 14
Uncovered lines: 6
Coverable lines: 20
Total lines: 48
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%
GetCustomers()100%11100%
GetCustomer()50%3245.45%

File(s)

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

#LineLine coverage
 1using Api.Extensions;
 2using Api.Request.Parameters;
 3using Application.service;
 4using Application.Service;
 5using Infrastructure.Entity;
 6using Microsoft.AspNetCore.Mvc;
 7
 8namespace Api.Controller.v1;
 9
 10[ApiController]
 11[Route("api/[controller]/[action]")]
 12[ApiVersion("1")]
 13[Produces("application/json")]
 14public class CustomerController : ControllerBase {
 15  private readonly ILogger<CustomerController> _logger;
 16  private readonly CustomerService _service;
 17
 418  public CustomerController(ILogger<CustomerController> logger, CustomerService service) {
 219    _logger = logger;
 220    _service = service;
 221  }
 22
 23  [HttpGet]
 24  [ProducesResponseType(typeof(customer[]), StatusCodes.Status200OK)]
 125  public async Task<IActionResult> GetCustomers(CancellationToken ct) {
 126    var results = await _service.FindAll(ct);
 127    _logger.LogResults(typeof(employee), results);
 128    return Ok(results);
 129  }
 30
 31  [HttpGet]
 32  [ProducesResponseType(typeof(customer), StatusCodes.Status200OK)]
 33  [ProducesResponseType(StatusCodes.Status404NotFound)]
 134  public async Task<IActionResult> GetCustomer([FromQuery] CustomerRequest req, CancellationToken ct) {
 135    var result = await _service.FindById(req.CustomerID, ct);
 136    if (result is null) {
 037      _logger.LogInformation("Customer {CustomerId} not found", req.CustomerID);
 038      return NotFound(new ProblemDetails {
 039        Title = "Customer not found",
 040        Status = StatusCodes.Status404NotFound,
 041        Detail = $"Not customer with id „{req.CustomerID}“ exists",
 042      });
 43    }
 144    return Ok(result);
 145  }
 46
 47
 48}