mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-12 03:57:32 +00:00
Extension method for getting the immediate interfaces on a Type
This commit is contained in:
parent
fb6ee9d468
commit
1ac5e26992
2 changed files with 47 additions and 0 deletions
|
|
@ -1,4 +1,6 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ICD.Common.Utils.Extensions;
|
||||
using NUnit.Framework;
|
||||
|
|
@ -93,6 +95,20 @@ namespace ICD.Common.Utils.Tests.Extensions
|
|||
Assert.IsTrue(baseTypes.Contains(typeof(object)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetImmediateInterfacesTest()
|
||||
{
|
||||
Type[] interfaces = typeof(ICollection<int>).GetImmediateInterfaces().ToArray();
|
||||
|
||||
Assert.AreEqual(1, interfaces.Length);
|
||||
Assert.AreEqual(typeof(IEnumerable<int>), interfaces[0]);
|
||||
|
||||
interfaces = typeof(IEnumerable<int>).GetImmediateInterfaces().ToArray();
|
||||
|
||||
Assert.AreEqual(1, interfaces.Length);
|
||||
Assert.AreEqual(typeof(IEnumerable), interfaces[0]);
|
||||
}
|
||||
|
||||
private interface C
|
||||
{
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue