< Summary

Information
Class: KT.Modules.Report.Presentation.Dto.WebSocket.ReportNotification
Assembly: KT.Modules.Report
File(s): G:\NetProjects\KeepTrack\src\Modules\KT.Modules.Report\Core\Application\ReportNotification.cs
Line coverage
56%
Covered lines: 9
Uncovered lines: 7
Coverable lines: 16
Total lines: 101
Line coverage: 56.2%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Type()100%11100%
get_Report()100%11100%
Create(...)100%210%
DeleteReportNotification(...)100%11100%

File(s)

G:\NetProjects\KeepTrack\src\Modules\KT.Modules.Report\Core\Application\ReportNotification.cs

#LineLine coverage
 1using KT.Modules.Report.Core.Domain;
 2using System.Text.Json.Serialization;
 3
 4namespace KT.Modules.Report.Presentation.Dto.WebSocket
 5{
 6
 7    internal class LocationAdd
 8    {
 9        public float Latitude { get; set; }
 10        public float Longitude { get; set; }
 11        public Locality Locality { get; set; }
 12        public required string Neighbourhood { get; set; }
 13    }
 14    [JsonDerivedType(typeof(ReportDataAdd))]
 15    [JsonDerivedType(typeof(ReportDataDelete))]
 16    internal class ReportData
 17    {
 18
 19    }
 20    internal class ReportDataAdd : ReportData
 21    {
 22        public required string Id { get; set; }
 23        public string UserId { get; set; }
 24        public LocationAdd Location { get; set; }
 25        public ReportType Type { get; set; }
 26        public string? Description { get; set; }
 27        public string? Title { get; set; }
 28        public DateTime CreatedAt { get; set; }
 29        public DateTime UpdatedAt { get; set; }
 30
 31        public static ReportDataAdd fromDomain (Core.Domain.Report report)
 32        {
 33            var location = new LocationAdd
 34            {
 35                Latitude = report.Location.Latitude,
 36                Longitude = report.Location.Longitude,
 37                Locality = report.Location.Locality,
 38                Neighbourhood = report.Location.Neighbourhood
 39            };
 40
 41            return new ReportDataAdd
 42            {
 43                Id = report.Id,
 44                UserId = report.UserId,
 45                Location = location,
 46                Type = report.Type,
 47                Description = report.Description,
 48                Title = report.Title,
 49                CreatedAt = report.CreatedAt,
 50                UpdatedAt = report.UpdatedAt,
 51            };
 52        }
 53    }
 54
 55    internal class ReportDataDelete : ReportData
 56    {
 57        public required string Id { get; set; }
 58
 59        public static ReportDataDelete fromDomain(Core.Domain.Report report)
 60        {
 61            return new ReportDataDelete
 62            {
 63                Id = report.Id,
 64            };
 65        }
 66    }
 67
 68    internal enum ReportNotificaionType
 69    {
 70        CREATE = 0,
 71        UPDATE = 1,
 72        DELETE = 2,
 73    }
 74
 75    internal class  ReportNotification
 76    {
 477        public required ReportNotificaionType Type { get; set; }
 478        public required ReportData Report { get; set; }
 79
 80
 81
 82        public static ReportNotification Create (ReportData reportData, ReportNotificaionType type)
 083        {
 084            return new ReportNotification
 085            {
 086                Type = type,
 087                Report = reportData
 088            };
 089        }
 90
 91        public static ReportNotification DeleteReportNotification(string reportId)
 192        {
 193            return new ReportNotification
 194            {
 195                Type = ReportNotificaionType.DELETE,
 196                Report = new ReportDataDelete { Id = reportId }
 197            };
 198        }
 99    }
 100
 101}