< Summary

Information
Class: Api.Controller.v1.ProductController
Assembly: Api
File(s): /home/runner/work/Northwind-Api/Northwind-Api/src/Api/Controller/v1/ProductController.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 18
Coverable lines: 18
Total lines: 47
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
CreateProduct()0%620%
UpdateProduct()100%210%
PatchProduct()100%210%
DeleteProduct()100%210%

File(s)

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

#LineLine coverage
 1using System.Reflection;
 2using System.Text.Json;
 3using Api.Extensions;
 4using Application.Service;
 5using Infrastructure.Entity;
 6using Microsoft.AspNetCore.Mvc;
 7using Microsoft.EntityFrameworkCore;
 8namespace Api.Controller.v1;
 9
 10[ApiController]
 11[Route("api/[controller]/[action]")]
 12[ApiVersion("1")]
 13[Produces("application/json")]
 14public class ProductController : ControllerBase {
 15  private readonly ILogger<ProductController> _logger;
 16  private readonly ProductService _service;
 17
 18
 19  [HttpPost]
 020  public async Task<IActionResult> CreateProduct([FromBody] product product) {
 021    if (product == null) {
 022      return BadRequest("Product is null.");
 23    }
 024    await Task.Delay(1);
 025    return CreatedAtAction(nameof(CreateProduct), new { id = product.product_id }, product);
 026  }
 27
 28  [HttpPut("{id}")]
 029  public async Task<IActionResult> UpdateProduct(int id, [FromBody] product product) {
 030    await Task.Delay(1);
 031    return NoContent();
 032  }
 33
 34  [HttpPatch("{id}")]
 035  public async Task<IActionResult> PatchProduct(int id, [FromBody] JsonElement updates) {
 036    await Task.Delay(1);
 037    return Ok();
 038  }
 39
 40  // DELETE: api/Products/5
 41  [HttpDelete("{id}")]
 042  public async Task<IActionResult> DeleteProduct(int id) {
 043    await Task.Delay(1);
 044    return NoContent();
 045  }
 46}
 47