Пример #1
0
            public void Should_Throw_If_Method_Is_Null()
            {
                // Given, When
                var result = Record.Exception(() => RoslynMethodAliasGenerator.Generate(null));

                // Then
                Assert.IsArgumentNullException(result, "method");
            }
Пример #2
0
            public void Should_Return_Correctly_Generated_Wrapper_For_Generic_Type_Without_Arguments()
            {
                const string expected = "public void Generic_ExtensionMethod<TTest>(){" +
                                        "Cake.Tests.Fixtures.RoslynMethodAliasGeneratorFixture.Generic_ExtensionMethod<TTest>" +
                                        "(Context);}";

                var method = typeof(RoslynMethodAliasGeneratorFixture).GetMethods().SingleOrDefault(x => x.Name == "Generic_ExtensionMethod");

                // When
                var result = RoslynMethodAliasGenerator.Generate(method);

                // Then
                Assert.Equal(expected, result);
            }
Пример #3
0
            public void Should_Return_Correctly_Generated_Wrapper_For_Method_With_Return_Value()
            {
                const string expected = "public System.String NonGeneric_ExtensionMethodWithReturnValue(){" +
                                        "return Cake.Tests.Fixtures.RoslynMethodAliasGeneratorFixture.NonGeneric_ExtensionMethodWithReturnValue" +
                                        "(Context);}";

                var method = typeof(RoslynMethodAliasGeneratorFixture).GetMethod("NonGeneric_ExtensionMethodWithReturnValue");

                // When
                var result = RoslynMethodAliasGenerator.Generate(method);

                // Then
                Assert.Equal(expected, result);
            }
Пример #4
0
            public void Should_Return_Correctly_Generated_Wrapper_For_Non_Generic_Type_With_Generic_Argument()
            {
                const string expected = "public void NonGeneric_ExtensionMethodWithGenericParameter(System.Action<System.Int32> value){" +
                                        "Cake.Tests.Fixtures.RoslynMethodAliasGeneratorFixture.NonGeneric_ExtensionMethodWithGenericParameter" +
                                        "(Context, value);}";

                var method = typeof(RoslynMethodAliasGeneratorFixture).GetMethod("NonGeneric_ExtensionMethodWithGenericParameter");

                // When
                var result = RoslynMethodAliasGenerator.Generate(method);

                // Then
                Assert.Equal(expected, result);
            }