< Summary

Information
Class: MyNet.IO.AutoSave.AutoSaveFeature
Assembly: MyNet.IO
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.IO/AutoSave/AutoSaveFeature.cs
Tag: 323_28699572109
Line coverage
100%
Covered lines: 7
Uncovered lines: 0
Coverable lines: 7
Total lines: 49
Line coverage: 100%
Branch coverage
75%
Covered branches: 3
Total branches: 4
Branch coverage: 75%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Enable()100%11100%
Disable()100%11100%
Set(...)75%44100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.IO/AutoSave/AutoSaveFeature.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="AutoSaveFeature.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System;
 8
 9namespace MyNet.IO.AutoSave;
 10
 11/// <summary>
 12/// Represents the auto-save feature, allowing to enable or disable it and notifying about changes in its state.
 13/// </summary>
 14public sealed class AutoSaveFeature : IAutoSaveFeature
 15{
 16    /// <summary>
 17    /// Gets a value indicating whether the auto-save feature is currently enabled.
 18    /// </summary>
 19    public bool IsEnabled { get; private set; }
 20
 21    /// <summary>
 22    /// Occurs when the state of the auto-save feature changes. The event handler receives a boolean value indicating th
 23    /// </summary>
 24    public event EventHandler<AutoSaveEnabledChangedEventArgs>? Changed;
 25
 26    /// <summary>
 27    /// Enables the auto-save feature. If the feature is already enabled, this method does nothing. If the state changes
 28    /// </summary>
 629    public void Enable() => Set(true);
 30
 31    /// <summary>
 32    /// Disables the auto-save feature. If the feature is already disabled, this method does nothing. If the state chang
 33    /// </summary>
 334    public void Disable() => Set(false);
 35
 36    /// <summary>
 37    /// Sets the state of the auto-save feature to the specified value. If the new value is the same as the current stat
 38    /// </summary>
 39    /// <param name="value">The new state of the auto-save feature.</param>
 40    private void Set(bool value)
 41    {
 942        if (IsEnabled == value)
 343            return;
 44
 645        IsEnabled = value;
 646        Changed?.Invoke(this, new(value));
 647    }
 48}
 49