< Summary

Information
Class: MyNet.Observable.ValidationExtensions
Assembly: MyNet.Observable
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Observable/Behaviors/Extensions/ValidationExtensions.cs
Tag: 323_28699572109
Line coverage
50%
Covered lines: 1
Uncovered lines: 1
Coverable lines: 2
Total lines: 30
Line coverage: 50%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Validate(...)100%22100%
ValidateGraph(...)100%210%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Observable/Behaviors/Extensions/ValidationExtensions.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="ValidationExtensions.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using MyNet.Observable.Behaviors;
 8
 9#pragma warning disable IDE0130 // Namespace does not match folder structure
 10namespace MyNet.Observable;
 11#pragma warning restore IDE0130 // Namespace does not match folder structure
 12
 13public static class ValidationExtensions
 14{
 15    extension(ObservableObject owner)
 16    {
 17        /// <summary>
 18        /// Validates the current state of the object by checking if it implements the IValidationBehavior behavior and 
 19        /// </summary>
 20        /// <returns>True if the object is valid; otherwise, false.</returns>
 2721        public bool Validate() => owner.Behaviors.TryGet<IValidationBehavior>(out var behavior) && behavior.Validate();
 22
 23        /// <summary>
 24        /// Validates the current state of the object by traversing its behavior graph and checking if any behavior in t
 25        /// </summary>
 26        /// <returns>True if all behaviors in the graph are valid; otherwise, false.</returns>
 027        public bool ValidateGraph() => ValidationGraphVisitor.Validate(owner);
 28    }
 29}
 30