• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Aldaviva / PowerOverInternet / 15674990315

16 Jun 2025 07:50AM UTC coverage: 90.566% (-9.4%) from 100.0%
15674990315

push

github

Aldaviva
.NET 8 no longer includes packages.lock.json in the publishing output directory, unlike .NET 6

14 of 20 branches covered (70.0%)

48 of 53 relevant lines covered (90.57%)

4.42 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.35
/PowerOverInternet/Controllers/PowerController.cs
1
using Microsoft.AspNetCore.Mvc;
2
using PowerOverInternet.Services;
3

4
namespace PowerOverInternet.Controllers;
5

6
[ApiController]
7
[Route("[controller]")]
8
public class PowerController(ILogger<PowerController> logger, OutletService outletService): ControllerBase {
8✔
9

10
    [HttpPut]
11
    public IActionResult setOutletPower([FromQuery] string outletHostname, [FromQuery] OutletAction turnOn, [FromQuery] int? socketId = null, [FromQuery] int delaySec = 0) {
12
        delaySec = Math.Max(0, delaySec);
8✔
13
        string action = turnOn switch {
8!
14
            OutletAction.FALSE  => "turn off",
4✔
15
            OutletAction.TRUE   => "turn on",
4✔
16
            OutletAction.TOGGLE => "toggle"
×
17
        };
8✔
18
        logger.LogInformation("{name} will {action} in {sec:N0} seconds", outletHostname, action, delaySec);
8✔
19

20
        Task.Delay(TimeSpan.FromSeconds(delaySec)).ContinueWith(async _ => {
8✔
21
            try {
8✔
22
                logger.LogInformation("{name} will {action} now", outletHostname, action);
8✔
23
                await outletService.setPowerState(outletHostname, turnOn, socketId);
8✔
24
            } catch (Exception e) when (e is not OutOfMemoryException) {
8✔
25
                logger.LogError(e, "Uncaught exception setting outlet {name} power state to {action} after delay", outletHostname, action);
×
26
            }
×
27
        });
16✔
28

29
        return NoContent();
8✔
30
    }
31

32
}
33

34
public enum OutletAction {
35

36
    FALSE,
37
    TRUE,
38
    TOGGLE
39

40
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc