# WireMock.Validation.Check - Coverage Report

# Summary

Class: | WireMock.Validation.Check
Assembly: | WireMock.Net
File(s): | C:\Users\azureuser\Documents\Github\WireMock.Net\src\WireMock.Net\Validation\Check.cs
Covered lines: | 27
Uncovered lines: | 44
Coverable lines: | 71
Total lines: | 139
Line coverage: | 38%
Branch coverage: | 35%

# Metrics

Method | Cyclomatic complexity | NPath complexity | Sequence coverage | Branch coverage
--- | --- | --- | --- | ---
Condition(...) | 2 | 2 | 66.67 | 66.67
NotNull(...) | 2 | 2 | 57.14 | 66.67
NotNull(...) | 2 | 2 | 0 | 0
NotNullOrEmpty(...) | 2 | 2 | 62.5 | 66.67
NotNullOrEmpty(...) | 4 | 8 | 43.75 | 57.14
NullButNotEmpty(...) | 3 | 2 | 0 | 0
HasNoNulls(...) | 3 | 2 | 62.5 | 66.67
ValidEntityType(...) | 2 | 2 | 0 | 0

# File(s)

## C:\Users\azureuser\Documents\Github\WireMock.Net\src\WireMock.Net\Validation\Check.cs

| # | Line |  | Line coverage
--- | --- | --- | --- | ---
|  | `1` |  | `// Copyright (c) .NET Foundation. All rights reserved.`
|  | `2` |  | `// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.`
|  | `3` |  | ``
|  | `4` |  | `using System;`
|  | `5` |  | `using System.Collections.Generic;`
|  | `6` |  | `using System.Diagnostics;`
|  | `7` |  | `using System.Linq;`
|  | `8` |  | `using System.Reflection;`
|  | `9` |  | `using JetBrains.Annotations;`
|  | `10` |  | ``
|  | `11` |  | `// Copied from https://github.com/aspnet/EntityFramework/blob/dev/src/Shared/Check.cs`
|  | `12` |  | `namespace WireMock.Validation`
|  | `13` |  | `{`
|  | `14` |  | `// [ExcludeFromCodeCoverage]`
|  | `15` |  | `[DebuggerStepThrough]`
|  | `16` |  | `internal static class Check`
|  | `17` |  | `{`
|  | `18` |  | `[ContractAnnotation("value:null => halt")]`
|  | `19` |  | `public static T Condition<T>([NoEnumeration] T value, [NotNull] Predicate<T> condition, [InvokerParameterName] [`
| 2 | `20` |  | `{`
| 2 | `21` |  | `NotNull(condition, nameof(condition));`
| 2 | `22` |  | `NotNull(value, nameof(value));`
|  | `23` |  | ``
| 2 | `24` |  | `if (!condition(value))`
| 0 | `25` |  | `{`
| 0 | `26` |  | `NotNullOrEmpty(parameterName, nameof(parameterName));`
|  | `27` |  | ``
| 0 | `28` |  | `throw new ArgumentOutOfRangeException(parameterName);`
|  | `29` |  | `}`
|  | `30` |  | ``
| 2 | `31` |  | `return value;`
| 2 | `32` |  | `}`
|  | `33` |  | ``
|  | `34` |  | `[ContractAnnotation("value:null => halt")]`
|  | `35` |  | `public static T NotNull<T>([NoEnumeration] T value, [InvokerParameterName] [NotNull] string parameterName)`
| 1851 | `36` |  | `{`
| 1851 | `37` |  | `if (ReferenceEquals(value, null))`
| 0 | `38` |  | `{`
| 0 | `39` |  | `NotNullOrEmpty(parameterName, nameof(parameterName));`
|  | `40` |  | ``
| 0 | `41` |  | `throw new ArgumentNullException(parameterName);`
|  | `42` |  | `}`
|  | `43` |  | ``
| 1851 | `44` |  | `return value;`
| 1851 | `45` |  | `}`
|  | `46` |  | ``
|  | `47` |  | `[ContractAnnotation("value:null => halt")]`
|  | `48` |  | `public static T NotNull<T>([NoEnumeration] T value, [InvokerParameterName] [NotNull] string parameterName, [NotN`
| 0 | `49` |  | `{`
| 0 | `50` |  | `if (ReferenceEquals(value, null))`
| 0 | `51` |  | `{`
| 0 | `52` |  | `NotNullOrEmpty(parameterName, nameof(parameterName));`
| 0 | `53` |  | `NotNullOrEmpty(propertyName, nameof(propertyName));`
|  | `54` |  | ``
| 0 | `55` |  | `throw new ArgumentException(CoreStrings.ArgumentPropertyNull(propertyName, parameterName));`
|  | `56` |  | `}`
|  | `57` |  | ``
| 0 | `58` |  | `return value;`
| 0 | `59` |  | `}`
|  | `60` |  | ``
|  | `61` |  | `[ContractAnnotation("value:null => halt")]`
|  | `62` |  | `public static IList<T> NotNullOrEmpty<T>(IList<T> value, [InvokerParameterName] [NotNull] string parameterName)`
| 287 | `63` |  | `{`
| 287 | `64` |  | `NotNull(value, parameterName);`
|  | `65` |  | ``
| 287 | `66` |  | `if (value.Count == 0)`
| 0 | `67` |  | `{`
| 0 | `68` |  | `NotNullOrEmpty(parameterName, nameof(parameterName));`
|  | `69` |  | ``
| 0 | `70` |  | `throw new ArgumentException(CoreStrings.CollectionArgumentIsEmpty(parameterName));`
|  | `71` |  | `}`
|  | `72` |  | ``
| 287 | `73` |  | `return value;`
| 287 | `74` |  | `}`
|  | `75` |  | ``
|  | `76` |  | `[ContractAnnotation("value:null => halt")]`
|  | `77` |  | `public static string NotNullOrEmpty(string value, [InvokerParameterName] [NotNull] string parameterName)`
| 6 | `78` |  | `{`
| 6 | `79` |  | `Exception e = null;`
| 6 | `80` |  | `if (ReferenceEquals(value, null))`
| 0 | `81` |  | `{`
| 0 | `82` |  | `e = new ArgumentNullException(parameterName);`
| 0 | `83` |  | `}`
| 6 | `84` |  | `else if (value.Trim().Length == 0)`
| 0 | `85` |  | `{`
| 0 | `86` |  | `e = new ArgumentException(CoreStrings.ArgumentIsEmpty(parameterName));`
| 0 | `87` |  | `}`
|  | `88` |  | ``
| 6 | `89` |  | `if (e != null)`
| 0 | `90` |  | `{`
| 0 | `91` |  | `NotNullOrEmpty(parameterName, nameof(parameterName));`
|  | `92` |  | ``
| 0 | `93` |  | `throw e;`
|  | `94` |  | `}`
|  | `95` |  | ``
| 6 | `96` |  | `return value;`
| 6 | `97` |  | `}`
|  | `98` |  | ``
|  | `99` |  | `public static string NullButNotEmpty(string value, [InvokerParameterName] [NotNull] string parameterName)`
| 0 | `100` |  | `{`
| 0 | `101` |  | `if (!ReferenceEquals(value, null)`
| 0 | `102` |  | `&& (value.Length == 0))`
| 0 | `103` |  | `{`
| 0 | `104` |  | `NotNullOrEmpty(parameterName, nameof(parameterName));`
|  | `105` |  | ``
| 0 | `106` |  | `throw new ArgumentException(CoreStrings.ArgumentIsEmpty(parameterName));`
|  | `107` |  | `}`
|  | `108` |  | ``
| 0 | `109` |  | `return value;`
| 0 | `110` |  | `}`
|  | `111` |  | ``
|  | `112` |  | `public static IList<T> HasNoNulls<T>(IList<T> value, [InvokerParameterName] [NotNull] string parameterName)`
|  | `113` |  | `where T : class`
| 15 | `114` |  | `{`
| 15 | `115` |  | `NotNull(value, parameterName);`
|  | `116` |  | ``
| 32 | `117` |  | `if (value.Any(e => e == null))`
| 0 | `118` |  | `{`
| 0 | `119` |  | `NotNullOrEmpty(parameterName, nameof(parameterName));`
|  | `120` |  | ``
| 0 | `121` |  | `throw new ArgumentException(parameterName);`
|  | `122` |  | `}`
|  | `123` |  | ``
| 15 | `124` |  | `return value;`
| 15 | `125` |  | `}`
|  | `126` |  | ``
|  | `127` |  | `public static Type ValidEntityType(Type value, [InvokerParameterName] [NotNull] string parameterName)`
| 0 | `128` |  | `{`
| 0 | `129` |  | `if (!value.GetTypeInfo().IsClass)`
| 0 | `130` |  | `{`
| 0 | `131` |  | `NotNullOrEmpty(parameterName, nameof(parameterName));`
|  | `132` |  | ``
| 0 | `133` |  | `throw new ArgumentException(CoreStrings.InvalidEntityType(value, parameterName));`
|  | `134` |  | `}`
|  | `135` |  | ``
| 0 | `136` |  | `return value;`
| 0 | `137` |  | `}`
|  | `138` |  | `}`
|  | `139` |  | `}`

# Methods/Properties

Condition(T,System.Predicate`1<T>,System.String)
NotNull(T,System.String)
NotNull(T,System.String,System.String)
NotNullOrEmpty(System.Collections.Generic.IList`1<T>,System.String)
NotNullOrEmpty(System.String,System.String)
NullButNotEmpty(System.String,System.String)
HasNoNulls(System.Collections.Generic.IList`1<T>,System.String)
ValidEntityType(System.Type,System.String)