< Summary - Jellyfin

Information
Class: Jellyfin.Data.Entities.Security.Device
Assembly: Jellyfin.Data
File(s): /srv/git/jellyfin/Jellyfin.Data/Entities/Security/Device.cs
Line coverage
100%
Covered lines: 11
Uncovered lines: 0
Coverable lines: 11
Total lines: 107
Line coverage: 100%
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

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%

File(s)

/srv/git/jellyfin/Jellyfin.Data/Entities/Security/Device.cs

#LineLine coverage
 1using System;
 2using System.ComponentModel.DataAnnotations;
 3using System.ComponentModel.DataAnnotations.Schema;
 4using System.Globalization;
 5
 6namespace Jellyfin.Data.Entities.Security
 7{
 8    /// <summary>
 9    /// An entity representing a device.
 10    /// </summary>
 11    public class Device
 12    {
 13        /// <summary>
 14        /// Initializes a new instance of the <see cref="Device"/> class.
 15        /// </summary>
 16        /// <param name="userId">The user id.</param>
 17        /// <param name="appName">The app name.</param>
 18        /// <param name="appVersion">The app version.</param>
 19        /// <param name="deviceName">The device name.</param>
 20        /// <param name="deviceId">The device id.</param>
 21        public Device(Guid userId, string appName, string appVersion, string deviceName, string deviceId)
 22        {
 1623            UserId = userId;
 1624            AppName = appName;
 1625            AppVersion = appVersion;
 1626            DeviceName = deviceName;
 1627            DeviceId = deviceId;
 28
 1629            AccessToken = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
 1630            DateCreated = DateTime.UtcNow;
 1631            DateModified = DateCreated;
 1632            DateLastActivity = DateCreated;
 33
 34            // Non-nullable for EF Core, as this is a required relationship.
 1635            User = null!;
 1636        }
 37
 38        /// <summary>
 39        /// Gets the id.
 40        /// </summary>
 41        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
 42        public int Id { get; private set; }
 43
 44        /// <summary>
 45        /// Gets the user id.
 46        /// </summary>
 47        public Guid UserId { get; private set; }
 48
 49        /// <summary>
 50        /// Gets or sets the access token.
 51        /// </summary>
 52        public string AccessToken { get; set; }
 53
 54        /// <summary>
 55        /// Gets or sets the app name.
 56        /// </summary>
 57        [MaxLength(64)]
 58        [StringLength(64)]
 59        public string AppName { get; set; }
 60
 61        /// <summary>
 62        /// Gets or sets the app version.
 63        /// </summary>
 64        [MaxLength(32)]
 65        [StringLength(32)]
 66        public string AppVersion { get; set; }
 67
 68        /// <summary>
 69        /// Gets or sets the device name.
 70        /// </summary>
 71        [MaxLength(64)]
 72        [StringLength(64)]
 73        public string DeviceName { get; set; }
 74
 75        /// <summary>
 76        /// Gets or sets the device id.
 77        /// </summary>
 78        [MaxLength(256)]
 79        [StringLength(256)]
 80        public string DeviceId { get; set; }
 81
 82        /// <summary>
 83        /// Gets or sets a value indicating whether this device is active.
 84        /// </summary>
 85        public bool IsActive { get; set; }
 86
 87        /// <summary>
 88        /// Gets or sets the date created.
 89        /// </summary>
 90        public DateTime DateCreated { get; set; }
 91
 92        /// <summary>
 93        /// Gets or sets the date modified.
 94        /// </summary>
 95        public DateTime DateModified { get; set; }
 96
 97        /// <summary>
 98        /// Gets or sets the date of last activity.
 99        /// </summary>
 100        public DateTime DateLastActivity { get; set; }
 101
 102        /// <summary>
 103        /// Gets the user.
 104        /// </summary>
 105        public User User { get; private set; }
 106    }
 107}