< Summary

Class:SharpHoundCommonLib.Result
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:1
Total branches:2
Branch coverage:50% (1 of 2)

Metrics

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

File(s)

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

#LineLine coverage
 1namespace SharpHoundCommonLib {
 2    public class Result<T> : Result {
 3        public T Value { get; set; }
 4
 5        protected Result(T value, bool success, string error) : base(success, error) {
 6            Value = value;
 7        }
 8
 9        public new static Result<T> Fail(string message) {
 10            return new Result<T>(default, false, message);
 11        }
 12
 13        public static Result<T> Fail() {
 14            return new Result<T>(default, false, string.Empty);
 15        }
 16
 17        public static Result<T> Ok(T value) {
 18            return new Result<T>(value, true, string.Empty);
 19        }
 20    }
 21
 22    public class Result {
 23
 8824        public string Error { get; set; }
 3125        public bool IsSuccess => string.IsNullOrWhiteSpace(Error) && Success;
 8026        private bool Success { get; set; }
 27
 9828        protected Result(bool success, string error) {
 4929            Success = success;
 4930            Error = error;
 4931        }
 32
 033        public static Result Fail(string message) {
 034            return new Result(false, message);
 035        }
 36
 037        public static Result Ok() {
 038            return new Result(true, string.Empty);
 039        }
 40    }
 41}