Beispiel #1
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)");
        }
Beispiel #2
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)");
        }
Beispiel #3
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)");
        }
Beispiel #4
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)");
        }
Beispiel #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)");
        }
Beispiel #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)");
        }
Beispiel #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)");
        }
Beispiel #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)");
        }
Beispiel #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)");
        }
Beispiel #10
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();
        }