mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-09 23:45:42 +00:00
test: 100% coverage on Reflection extensions
This commit is contained in:
parent
303617a888
commit
d68d893abd
@ -1,4 +1,5 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System.Reflection;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using X10D.Reflection;
|
||||
|
||||
namespace X10D.Tests.Reflection;
|
||||
@ -69,10 +70,14 @@ public class MemberInfoTests
|
||||
Assert.ThrowsException<ArgumentNullException>(() =>
|
||||
(type!.SelectFromCustomAttribute((CLSCompliantAttribute attribute) => attribute.IsCompliant, true)));
|
||||
|
||||
Assert.ThrowsException<ArgumentNullException>(() =>
|
||||
{
|
||||
const BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.NonPublic |
|
||||
BindingFlags.Instance | BindingFlags.Static;
|
||||
var memberInfo = typeof(int).GetMembers(bindingFlags)[0];
|
||||
Func<CLSCompliantAttribute, bool>? selector = null;
|
||||
typeof(int).SelectFromCustomAttribute(selector!);
|
||||
});
|
||||
|
||||
Assert.ThrowsException<ArgumentNullException>(() => typeof(int).SelectFromCustomAttribute(selector!));
|
||||
Assert.ThrowsException<ArgumentNullException>(() => typeof(int).SelectFromCustomAttribute(selector!, default));
|
||||
Assert.ThrowsException<ArgumentNullException>(() => memberInfo.SelectFromCustomAttribute(selector!));
|
||||
Assert.ThrowsException<ArgumentNullException>(() => memberInfo.SelectFromCustomAttribute(selector!, default));
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ public class TypeTests
|
||||
{
|
||||
Assert.ThrowsException<ArgumentNullException>(() => typeof(object).Inherits(null!));
|
||||
Assert.ThrowsException<ArgumentNullException>(() => ((Type?)null)!.Inherits(typeof(object)));
|
||||
Assert.ThrowsException<ArgumentNullException>(() => ((Type?)null)!.Inherits<object>());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -47,7 +48,8 @@ public class TypeTests
|
||||
public void Implements_ShouldThrow_GivenNull()
|
||||
{
|
||||
Assert.ThrowsException<ArgumentNullException>(() => typeof(object).Implements(null!));
|
||||
Assert.ThrowsException<ArgumentNullException>(() => ((Type?)null)!.Implements(typeof(object)));
|
||||
Assert.ThrowsException<ArgumentNullException>(() => ((Type?)null)!.Implements(typeof(IComparable)));
|
||||
Assert.ThrowsException<ArgumentNullException>(() => ((Type?)null)!.Implements<IComparable>());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
Loading…
Reference in New Issue
Block a user