< Summary

Information
Class: MyNet.UI.Services.FileHistory.RecentFilesOperations
Assembly: MyNet.UI
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.UI/Services/FileHistory/RecentFilesOperations.cs
Tag: 323_28699572109
Line coverage
0%
Covered lines: 0
Uncovered lines: 15
Coverable lines: 15
Total lines: 59
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetAllAsync(...)100%210%
AddAsync()100%210%
RemoveAsync()0%620%
SetPinnedAsync()100%210%
NotifyChanged()0%620%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.UI/Services/FileHistory/RecentFilesOperations.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="RecentFilesOperations.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System;
 8using System.Collections.Generic;
 9using System.Threading;
 10using System.Threading.Tasks;
 11using MyNet.IO.FileHistory;
 12
 13namespace MyNet.UI.Services.FileHistory;
 14
 15/// <summary>
 16/// Wraps <see cref="IRecentFilesService"/> for UI scenarios and notifies subscribers when data changes.
 17/// </summary>
 18public sealed class RecentFilesOperations(IRecentFilesService recentFilesService) : IRecentFilesOperations
 19{
 20    /// <inheritdoc />
 21    public event EventHandler? Changed;
 22
 23    /// <inheritdoc />
 24    public Task<IReadOnlyList<RecentFile>> GetAllAsync(CancellationToken cancellationToken = default) =>
 025        recentFilesService.GetAllAsync();
 26
 27    /// <inheritdoc />
 28    public async Task<RecentFile?> AddAsync(string name, string path, bool isRecovered = false, CancellationToken cancel
 29    {
 30        _ = cancellationToken;
 031        var result = await recentFilesService.AddAsync(name, path, isRecovered).ConfigureAwait(false);
 032        NotifyChanged();
 033        return result;
 034    }
 35
 36    /// <inheritdoc />
 37    public async Task<bool> RemoveAsync(string path, CancellationToken cancellationToken = default)
 38    {
 39        _ = cancellationToken;
 040        var removed = await recentFilesService.RemoveAsync(path).ConfigureAwait(false);
 41
 042        if (removed)
 043            NotifyChanged();
 44
 045        return removed;
 046    }
 47
 48    /// <inheritdoc />
 49    public async Task<RecentFile?> SetPinnedAsync(string path, bool isPinned, CancellationToken cancellationToken = defa
 50    {
 51        _ = cancellationToken;
 052        var result = await recentFilesService.PinAsync(path, isPinned).ConfigureAwait(false);
 053        NotifyChanged();
 054        return result;
 055    }
 56
 057    private void NotifyChanged() => Changed?.Invoke(this, EventArgs.Empty);
 58}
 59