< Summary

Class:System.TypeExtensions
Assembly:Search.Management.Tests
File(s):C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Management.Search\tests\ModelComparer\TypeExtensions.cs
Covered lines:10
Uncovered lines:0
Coverable lines:10
Total lines:38
Line coverage:100% (10 of 10)
Covered branches:13
Total branches:16
Branch coverage:81.2% (13 of 16)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
CanBeNull(...)-100%100%
GetIEnumerable(...)-100%50%
ImplementsGenericEquatable(...)-100%50%
IsIEnumerable(...)-100%50%
IsInteger(...)-100%100%
IsNullable(...)-100%100%
IsReferenceType(...)-100%100%
IsGenericEnumerable(...)-100%100%
IsGenericEquatable(...)-100%100%
IsGenericWithDefinition(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Microsoft.Azure.Management.Search\tests\ModelComparer\TypeExtensions.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License. See License.txt in the project root for
 3// license information.
 4
 5using System.Collections.Generic;
 6using System.Linq;
 7using System.Reflection;
 8
 9namespace System
 10{
 11    public static class TypeExtensions
 12    {
 1776213        public static bool CanBeNull(this Type type) => type.IsReferenceType() || type.IsNullable();
 14
 15        public static Type GetIEnumerable(this Type type) =>
 799816            type.IsGenericEnumerable() ? type : type.GetTypeInfo().ImplementedInterfaces.FirstOrDefault(IsGenericEnumera
 17
 18        public static bool ImplementsGenericEquatable(this Type type) =>
 1477219            type.IsGenericEquatable() || type.GetTypeInfo().ImplementedInterfaces.Any(IsGenericEquatable);
 20
 21        public static bool IsIEnumerable(this Type type) =>
 69622            type.IsGenericEnumerable() || type.GetTypeInfo().ImplementedInterfaces.Any(IsGenericEnumerable);
 23
 24        public static bool IsInteger(this Type type) =>
 1625            type == typeof(byte) || type == typeof(short) || type == typeof(int) || type == typeof(long);
 26
 956027        public static bool IsNullable(this Type type) => type.IsGenericWithDefinition(typeof(Nullable<>));
 28
 1846629        public static bool IsReferenceType(this Type type) => !type.GetTypeInfo().IsValueType;
 30
 1473431        private static bool IsGenericEnumerable(this Type type) => type.IsGenericWithDefinition(typeof(IEnumerable<>));
 32
 4834633        private static bool IsGenericEquatable(this Type type) => type.IsGenericWithDefinition(typeof(IEquatable<>));
 34
 35        private static bool IsGenericWithDefinition(this Type type, Type genericTypeDef) =>
 7264036            type.GetTypeInfo().IsGenericType && type.GetGenericTypeDefinition() == genericTypeDef;
 37    }
 38}