< Summary

Class:SharpHoundCommonLib.Result<T>
Assembly:SharpHoundCommonLib
File(s):D:\a\SharpHoundCommon\SharpHoundCommon\src\CommonLib\Result.cs
Covered lines:7
Uncovered lines:6
Coverable lines:13
Total lines:41
Line coverage:53.8% (7 of 13)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%10100%
Fail(...)100%100%
Fail()100%100%
Ok(...)100%10100%

File(s)

D:\a\SharpHoundCommon\SharpHoundCommon\src\CommonLib\Result.cs

#LineLine coverage
 1namespace SharpHoundCommonLib {
 2    public class Result<T> : Result {
 703        public T Value { get; set; }
 4
 985        protected Result(T value, bool success, string error) : base(success, error) {
 496            Value = value;
 497        }
 8
 09        public new static Result<T> Fail(string message) {
 010            return new Result<T>(default, false, message);
 011        }
 12
 013        public static Result<T> Fail() {
 014            return new Result<T>(default, false, string.Empty);
 015        }
 16
 2017        public static Result<T> Ok(T value) {
 2018            return new Result<T>(value, true, string.Empty);
 2019        }
 20    }
 21
 22    public class Result {
 23
 24        public string Error { get; set; }
 25        public bool IsSuccess => string.IsNullOrWhiteSpace(Error) && Success;
 26        private bool Success { get; set; }
 27
 28        protected Result(bool success, string error) {
 29            Success = success;
 30            Error = error;
 31        }
 32
 33        public static Result Fail(string message) {
 34            return new Result(false, message);
 35        }
 36
 37        public static Result Ok() {
 38            return new Result(true, string.Empty);
 39        }
 40    }
 41}