コード例 #1
0
        public void CommonWalker_VisitParameter_Success_GetsInvoke()
        {
            var programText = @"
            namespace TestCompilation
            {
                public static class Program
                {
                    public static void test()
                    {
                        var c = CodeComponent.GetSum(1, 2);
                    }
                }

                public static class CodeComponent
                { 
                    public static int GetSum(int a, int b)
                    {
                        return a + b;
                    }
                }
            }";

            CommonAsserts.AssertSingleRelationAndSingleComponentByProgramText(
                programText, RelationType.Invoke, "TestCompilation", "CodeComponent",
                (model, classDeclaration) => new CommonWalker(model, classDeclaration, "TestCompilation"));
        }
コード例 #2
0
        public void ConstructorWalker_VisitParameter_Success_GetsReceiptByConstructorArgument()
        {
            var programText = @"
            namespace TestCompilation
            {
                public class Program
                {
                    private readonly CodeComponent component;

                    public Program(CodeComponent component)
                    {
                        this.component = component;
                    }
                }

                public class CodeComponent
                {
                    public int parameter { get; set; }
                }
            }";

            CommonAsserts.AssertSingleRelationAndSingleComponentByProgramText(
                programText, RelationType.ReceiptByConstructorArgument, "TestCompilation", "CodeComponent",
                (model, classDeclaration) => new ConstructorWalker(model, classDeclaration, "TestCompilation"));
        }
コード例 #3
0
        public void BaseListWalker_VisitParameter_Success_GetsInheritance()
        {
            var programText = @"
            namespace TestCompilation
            {
                public class AnotherCodeComponent : CodeComponent
                { }

                public class CodeComponent
                { }
            }";

            CommonAsserts.AssertSingleRelationAndSingleComponentByProgramText(
                programText, RelationType.Inheritance, "TestCompilation", "CodeComponent",
                (model, classDeclaration) => new BaseListWalker(model, classDeclaration, "TestCompilation"));
        }
コード例 #4
0
        public void CommonWalker_VisitParameter_Success_GetsReturnByFunction()
        {
            var programText = @"
            namespace TestCompilation
            {
                public abstract class Program
                {
                    public virtual CodeComponent GetCodeComponent(int parameter);
                }

                public class CodeComponent
                {
                    public int parameter { get; set; }
                }
            }";

            CommonAsserts.AssertSingleRelationAndSingleComponentByProgramText(
                programText, RelationType.ReturnByFunction, "TestCompilation", "CodeComponent",
                (model, classDeclaration) => new CommonWalker(model, classDeclaration, "TestCompilation"));
        }
コード例 #5
0
        public void CommonWalker_VisitParameter_Success_GetsInstantiate()
        {
            var programText = @"
            namespace TestCompilation
            {
                public class Program
                {
                    public CodeComponent Component => new CodeComponent();
                }

                public class CodeComponent
                { 
                    public int Parameter { get; set; }
                }
            }";

            CommonAsserts.AssertSingleRelationAndSingleComponentByProgramText(
                programText, RelationType.Instantiate, "TestCompilation", "CodeComponent",
                (model, classDeclaration) => new CommonWalker(model, classDeclaration, "TestCompilation"));
        }
コード例 #6
0
        public void CommonWalker_VisitParameter_Success_GetsThrow()
        {
            var programText = @"
            namespace TestCompilation
            {
                public class Program
                {
                    public void Test()
                    { 
                        throw new CustomException();
                    }
                }

                public class CustomException : System.Exception
                { }
            }";

            CommonAsserts.AssertSingleRelationAndSingleComponentByProgramText(
                programText, RelationType.Throw, "TestCompilation", "CustomException",
                (model, classDeclaration) => new CommonWalker(model, classDeclaration, "TestCompilation"));
        }
コード例 #7
0
        public void CommonWalker_VisitParameter_Success_GetsReceiptByMethodArgument()
        {
            var programText = @"
            namespace TestCompilation
            {
                public class Program
                {
                    public void Test(CodeComponent component)
                    { }
                }

                public class CodeComponent
                {
                    public int parameter { get; set; }
                }
            }";

            CommonAsserts.AssertSingleRelationAndSingleComponentByProgramText(
                programText, RelationType.ReceiptByMethodArgument, "TestCompilation", "CodeComponent",
                (model, classDeclaration) => new CommonWalker(model, classDeclaration, "TestCompilation"));
        }