예제 #1
0
        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)");
        }
예제 #2
0
        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)");
        }
예제 #3
0
        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)");
        }
예제 #4
0
        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)");
        }
예제 #5
0
        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)");
        }
예제 #6
0
        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)");
        }
예제 #7
0
        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)");
        }
예제 #8
0
        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)");
        }
예제 #9
0
        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)");
        }
예제 #10
0
        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());
        }
예제 #11
0
        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());
        }
예제 #12
0
        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();
        }