コード例 #1
0
        public void GetSafeTypeName_GenericGiven_ShouldReturnCorrespondingGenericExpression()
        {
            var type = typeof(Action <SampleStruct>);

            var result = CSharpSourceCodeGeneration.GetSafeTypeName(type);

            result.Should().Be("Action<SampleStruct>");
        }
コード例 #2
0
        public void GetParameterModifier_OutParameter_ShouldReturnOutKeyword()
        {
            var method    = typeof(SampleClass).GetMethod("Method10");
            var parameter = method.GetParameters()[1];
            var result    = CSharpSourceCodeGeneration.GetParameterModifier(parameter);

            result.Should().Be("out ");
        }
コード例 #3
0
        public void GetSafeTypeName_BuiltinTypeGiven_ShouldReturnShortenRepresentation()
        {
            var type = typeof(int);

            var result = CSharpSourceCodeGeneration.GetSafeTypeName(type);

            result.Should().Be("int");
        }
コード例 #4
0
        public void GetSafeTypeName_ArrayGiven_ShouldReturnArrayType()
        {
            var type = typeof(SampleClass[]);

            var result = CSharpSourceCodeGeneration.GetSafeTypeName(type);

            result.Should().Be("SampleClass[]");
        }
コード例 #5
0
        public void GetSafeTypeName_ClassGiven_ShouldReturnClassName()
        {
            var type = typeof(SampleClass);

            var result = CSharpSourceCodeGeneration.GetSafeTypeName(type);

            result.Should().Be(type.Name);
        }
コード例 #6
0
        public void GetParameterModifier_RefParameter_ShouldReturnRefKeyword()
        {
            var method    = typeof(SampleClass).GetMethod("Method8");
            var parameter = method.GetParameters()[0];
            var result    = CSharpSourceCodeGeneration.GetParameterModifier(parameter);

            result.Should().Be("ref ");
        }
コード例 #7
0
        public void GetParameterType_GenericParamsParameterGiven_ShouldReturnParamsKeyword()
        {
            var method    = typeof(SampleClass).GetMethod("Method11");
            var parameter = method.GetParameters()[0];

            var result = CSharpSourceCodeGeneration.GetParameterType(parameter);

            result.Should().Be("params TValue[] values");
        }
コード例 #8
0
        public void GetParameterType_DynamicParameterGiven_ShouldReturnDynamicKeyword()
        {
            var method    = typeof(SampleClass).GetMethod("Method9");
            var parameter = method.GetParameters()[0];

            var result = CSharpSourceCodeGeneration.GetParameterType(parameter);

            result.Should().Be("dynamic input");
        }
コード例 #9
0
        public void GetMethodCallArgumentsTest()
        {
            var method = typeof(SampleClass).GetMethod("Method10");

            CSharpSourceCodeGeneration.GetInvokingMethodArguments(method);
        }