public void TwoIntMethodSkippingFirst() { var method = typeof(Sample1).GetMethod("TwoIntParameters"); var sig = new MethodSignature(method); sig.MakeSignature(1).Should().Be("void TwoIntParameters(Int32 b)"); sig.MakeCall("this").Should().Be("TwoIntParameters(this, b)"); }
public void SingleStringRefMethod() { var method = typeof(Sample1).GetMethod("SingleStringRefParameter"); var sig = new MethodSignature(method); sig.MakeSignature().Should().Be("void SingleStringRefParameter(ref String a)"); sig.MakeCall().Should().Be("SingleStringRefParameter(ref a)"); }
public void GenericParameterInsideGenericClassWithConstraint() { var method = typeof(Sample2 <int>).GetMethod("GenericParameterInheriting"); var sig = new MethodSignature(method); sig.MakeSignature().Should().Be("void GenericParameterInheriting<Q>(Q a) where Q : MethodSignatureFixture.Sample1, IConvertible, new()"); sig.MakeCall().Should().Be("GenericParameterInheriting<Q>(a)"); }
public void TwoIntMethod() { var method = typeof(Sample1).GetMethod("TwoIntParameters"); var sig = new MethodSignature(method); sig.MakeSignature().Should().Be("void TwoIntParameters(Int32 a, Int32 b)"); sig.MakeCall().Should().Be("TwoIntParameters(a, b)"); }
public void GenericParameterInsideGenericClass() { var method = typeof(Sample2 <int>).GetMethod("GenericParameter"); var sig = new MethodSignature(method); sig.MakeSignature().Should().Be("void GenericParameter<Q>(Q a)"); sig.MakeCall().Should().Be("GenericParameter<Q>(a)"); }
public void StringEndsWithMethod() { var method = typeof(string).GetMethod("EndsWith", new[] { typeof(string), typeof(bool), typeof(CultureInfo) }); var sig = new MethodSignature(method); sig.MakeSignature().Should().Be("Boolean EndsWith(String value, Boolean ignoreCase, CultureInfo culture)"); sig.MakeCall().Should().Be("EndsWith(value, ignoreCase, culture)"); }
public void TwoConstrainedStructGenericParametersMethod() { var method = typeof(Sample1).GetMethod("TwoConstrainedStructGenericParameters"); var sig = new MethodSignature(method); sig.MakeSignature().Should().Be("void TwoConstrainedStructGenericParameters<T>(T a, T b) where T : struct, IConvertible"); sig.MakeCall().Should().Be("TwoConstrainedStructGenericParameters<T>(a, b)"); }
public void OneGenericParamsParametersMethod() { var method = typeof(Sample1).GetMethod("OneGenericParamsParameters"); var sig = new MethodSignature(method); sig.MakeSignature().Should().Be("void OneGenericParamsParameters<T>(params T[] a)"); sig.MakeCall().Should().Be("OneGenericParamsParameters<T>(a)"); }
public void TwoGenericParametersMethod() { var method = typeof(Sample1).GetMethod("TwoGenericParameters"); var sig = new MethodSignature(method); sig.MakeSignature().Should().Be("void TwoGenericParameters<T>(T a, T b)"); sig.MakeCall().Should().Be("TwoGenericParameters<T>(a, b)"); }
public void NamespacesForSingleSelfMethod() { var method = typeof(Sample1).GetMethod("SingleSelfParameter"); var sig = new MethodSignature(method); sig.MakeSignature(); var expected = new[] { "System", "Simple.Tests.Reflection" }; CollectionAssert.AreEquivalent(expected, sig.Namespaces.ToArray()); }
public void NamespacesForSeveralGenericParameters() { var method = typeof(Sample2 <int>).GetMethod("SeveralClasses"); var sig = new MethodSignature(method); sig.MakeSignature(); var expected = new[] { "Simple.Tests.Reflection", "System.Collections", "System.Collections.Generic" }; CollectionAssert.AreEquivalent(expected, sig.Namespaces.ToArray()); }
public void SeveralGenericParameters() { var method = typeof(Sample2 <int>).GetMethod("SeveralClasses"); var sig = new MethodSignature(method); Assert.AreEqual( "A SeveralClasses<A, B, C>(B b, C c) where A : struct where B : class, ICollection, IEnumerable, IList, new() where C : List<B>, ICollection, ICollection<B>, IEnumerable, IEnumerable<B>, IList, IList<B>, new()", sig.MakeSignature()); sig.MakeCall().Should().Be("SeveralClasses<A, B, C>(b, c)"); sig.ReturnsVoid.Should().Be.False(); }