< Summary - Jellyfin

Information
Class: Emby.Naming.Video.FileStack
Assembly: Emby.Naming
File(s): /srv/git/jellyfin/Emby.Naming/Video/FileStack.cs
Line coverage
75%
Covered lines: 3
Uncovered lines: 1
Coverable lines: 4
Total lines: 56
Line coverage: 75%
Branch coverage
75%
Covered branches: 3
Total branches: 4
Branch coverage: 75%
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%
ContainsFile(...)75%4.59466.66%

File(s)

/srv/git/jellyfin/Emby.Naming/Video/FileStack.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using Jellyfin.Extensions;
 4
 5namespace Emby.Naming.Video
 6{
 7    /// <summary>
 8    /// Object holding list of files paths with additional information.
 9    /// </summary>
 10    public class FileStack
 11    {
 12        /// <summary>
 13        /// Initializes a new instance of the <see cref="FileStack"/> class.
 14        /// </summary>
 15        /// <param name="name">The stack name.</param>
 16        /// <param name="isDirectory">Whether the stack files are directories.</param>
 17        /// <param name="files">The stack files.</param>
 18        public FileStack(string name, bool isDirectory, IReadOnlyList<string> files)
 19        {
 20            Name = name;
 21            IsDirectoryStack = isDirectory;
 22            Files = files;
 5823        }
 24
 25        /// <summary>
 26        /// Gets the name of file stack.
 27        /// </summary>
 28        public string Name { get; }
 29
 30        /// <summary>
 31        /// Gets the list of paths in stack.
 32        /// </summary>
 33        public IReadOnlyList<string> Files { get; }
 34
 35        /// <summary>
 36        /// Gets a value indicating whether stack is directory stack.
 37        /// </summary>
 38        public bool IsDirectoryStack { get; }
 39
 40        /// <summary>
 41        /// Helper function to determine if path is in the stack.
 42        /// </summary>
 43        /// <param name="file">Path of desired file.</param>
 44        /// <param name="isDirectory">Requested type of stack.</param>
 45        /// <returns>True if file is in the stack.</returns>
 46        public bool ContainsFile(string file, bool isDirectory)
 47        {
 4248            if (string.IsNullOrEmpty(file))
 49            {
 050                return false;
 51            }
 52
 4253            return IsDirectoryStack == isDirectory && Files.Contains(file, StringComparison.OrdinalIgnoreCase);
 54        }
 55    }
 56}