< Summary

Information
Class: FLP.Core.Context.Main.Bug
Assembly: FLP.Core
File(s): /home/runner/work/FLP.AzureFunctions/FLP.AzureFunctions/FLP.Core/Context/Main/Bug.cs
Line coverage
86%
Covered lines: 20
Uncovered lines: 3
Coverable lines: 23
Total lines: 52
Line coverage: 86.9%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
get_Title()100%11100%
get_Description()100%11100%
get_Status()100%11100%
get_ResolvedAt()100%11100%
get_AssignedToUserId()100%11100%
UpdateStatus(...)100%22100%
IsBugResolvedOrClosed(...)100%22100%
IsBugResolvedOrClosed()100%210%

File(s)

/home/runner/work/FLP.AzureFunctions/FLP.AzureFunctions/FLP.Core/Context/Main/Bug.cs

#LineLine coverage
 1using FLP.Core.Context.Constants;
 2using FLP.Core.Context.Shared;
 3
 4namespace FLP.Core.Context.Main;
 5
 6public class Bug : BasicModel<Guid>
 7{
 188    public Bug()
 189    {
 1810        Status = BugStatus.Open; // Default status for a new bug
 1811    }
 4012    public string? Title { get; set; }
 3013    public string? Description { get; set; }
 7214    public BugStatus Status { get; private set; } // e.g., "Open", "In Progress", "Resolved"
 2715    public DateTime? ResolvedAt { get; private set; } // Nullable to allow for unresolved bugs
 3016    public Guid? AssignedToUserId { get; set; } // Nullable to allow for unassigned bugs
 17
 18    /// <summary>
 19    /// Updates the status of the bug and sets ResolvedAt if the status is changed to Resolved.
 20    /// </summary>
 21    /// <param name="newStatus"></param>
 22    public void UpdateStatus(BugStatus newStatus)
 423    {
 424        Status = newStatus;
 25        // Automatically set ResolvedAt when status changes to Resolved
 426        if (IsBugResolvedOrClosed(newStatus))
 227        {
 228            ResolvedAt = DateTime.UtcNow; // Set resolved time when status is changed to Resolved
 229        }
 30        else
 231        {
 232            ResolvedAt = null; // Clear resolved time for statuses other than Resolved
 233        }
 434    }
 35
 36    /// <summary>
 37    /// Checks if the bug status is either Resolved or Closed.
 38    /// </summary>
 39    /// <param name="status"></param>
 40    /// <returns></returns>
 41    public static bool IsBugResolvedOrClosed(BugStatus status)
 842        => status == BugStatus.Resolved || status == BugStatus.Closed;
 43
 44    /// <summary>
 45    /// Checks if the current bug status is either Resolved or Closed.
 46    /// </summary>
 47    /// <returns></returns>
 48    public bool IsBugResolvedOrClosed()
 049    {
 050        return IsBugResolvedOrClosed(Status);
 051    }
 52}