Exemplo n.º 1
0
        public void GetFunctionEntryPoint_WithSingleMethod_ReturnsMethod()
        {
            var resolver = new FunctionEntryPointResolver();

            var method = resolver.GetFunctionEntryPoint(new[] { new TestMethodReference("MethodName", true) });

            Assert.NotNull(method);
            Assert.Equal("MethodName", method.Name);
        }
        public void GetFunctionEntryPoint_WithSingleMethod_ReturnsMethod()
        {
            var resolver = new FunctionEntryPointResolver();

            var method = resolver.GetFunctionEntryPoint(new[] { new TestMethodReference("MethodName", true) });

            Assert.NotNull(method);
            Assert.Equal("MethodName", method.Name);
        }
        public void GetFunctionEntryPoint_WithNoPublicMethods_ThrowsCompilationException()
        {
            var resolver = new FunctionEntryPointResolver();

            CompilationErrorException exc = Assert.Throws(typeof(CompilationErrorException), () => resolver.GetFunctionEntryPoint(new[]
             {
                new TestMethodReference("Run", false),
                new TestMethodReference("PrivateMethodName", false)
            })) as CompilationErrorException;

            var diagnostic = exc.Diagnostics.First();
            Assert.Equal(DotNetConstants.MissingFunctionEntryPointCompilationCode, diagnostic.Id); 
        }
Exemplo n.º 4
0
        public void GetFunctionEntryPoint_WithNoPublicMethods_ThrowsCompilationException()
        {
            var resolver = new FunctionEntryPointResolver();

            CompilationErrorException exc = Assert.Throws(typeof(CompilationErrorException), () => resolver.GetFunctionEntryPoint(new[]
            {
                new TestMethodReference("Run", false),
                new TestMethodReference("PrivateMethodName", false)
            })) as CompilationErrorException;

            var diagnostic = exc.Diagnostics.First();

            Assert.Equal(DotNetConstants.MissingFunctionEntryPointCompilationCode, diagnostic.Id);
        }
        public void GetFunctionEntryPoint_WithMultiplePublicRunMethods_ThrowsCompilationException()
        {
            var resolver = new FunctionEntryPointResolver();

            CompilationErrorException exc = Assert.Throws(typeof(CompilationErrorException), () => resolver.GetFunctionEntryPoint(new[]
             {
                new TestMethodReference("Run", true),
                new TestMethodReference("Run", true),
                new TestMethodReference("Run", true)
            })) as CompilationErrorException;

            var diagnostic = exc.Diagnostics.First();
            Assert.Equal(DotNetConstants.AmbiguousFunctionEntryPointsCompilationCode, diagnostic.Id);
        }
Exemplo n.º 6
0
        public void GetFunctionEntryPoint_WithNamedMethod_ReturnsNamedMethod()
        {
            var resolver = new FunctionEntryPointResolver("NamedMethod");

            var method = resolver.GetFunctionEntryPoint(new[]
            {
                new TestMethodReference("NamedMethod", true),
                new TestMethodReference("Run", true),
                new TestMethodReference("Run", true),
                new TestMethodReference("PrivateMethodName", false),
            });

            Assert.NotNull(method);
            Assert.Equal("NamedMethod", method.Name);
        }
Exemplo n.º 7
0
        public void GetFunctionEntryPoint_WithMultiplePublicRunMethods_ThrowsCompilationException()
        {
            var resolver = new FunctionEntryPointResolver();

            CompilationErrorException exc = Assert.Throws(typeof(CompilationErrorException), () => resolver.GetFunctionEntryPoint(new[]
            {
                new TestMethodReference("Run", true),
                new TestMethodReference("Run", true),
                new TestMethodReference("Run", true)
            })) as CompilationErrorException;

            var diagnostic = exc.Diagnostics.First();

            Assert.Equal(DotNetConstants.AmbiguousFunctionEntryPointsCompilationCode, diagnostic.Id);
        }
Exemplo n.º 8
0
        public void GetFunctionEntryPoint_WithMultiplePublicMethodsAndRunMethod_ReturnsRunMethod()
        {
            var resolver = new FunctionEntryPointResolver();

            var method = resolver.GetFunctionEntryPoint(new[]
            {
                new TestMethodReference("MethodName", true),
                new TestMethodReference("MethodName1", true),
                new TestMethodReference("Run", true),
                new TestMethodReference("PrivateMethodName3", false),
            });

            Assert.NotNull(method);
            Assert.Equal("Run", method.Name);
        }
Exemplo n.º 9
0
        public void GetFunctionEntryPoint_WithMissingNamedMethod_ThrowsCompilationException()
        {
            var resolver = new FunctionEntryPointResolver("NamedMethod");

            CompilationErrorException exc = Assert.Throws(typeof(CompilationErrorException), () => resolver.GetFunctionEntryPoint(new[]
            {
                new TestMethodReference("Method1", true),
                new TestMethodReference("Method2", true),
                new TestMethodReference("NamedMethod", false)
            })) as CompilationErrorException;

            var diagnostic = exc.Diagnostics.First();

            Assert.Equal(DotNetConstants.InvalidEntryPointNameCompilationCode, diagnostic.Id);
        }
        public void GetFunctionEntryPoint_WithMultiplePublicMethodsAndRunMethod_ReturnsRunMethod()
        {
            var resolver = new FunctionEntryPointResolver();

            var method = resolver.GetFunctionEntryPoint(new[]
            {
                new TestMethodReference("MethodName", true),
                new TestMethodReference("MethodName1", true),
                new TestMethodReference("Run", true),
                new TestMethodReference("PrivateMethodName3", false),
            });

            Assert.NotNull(method);
            Assert.Equal("Run", method.Name);
        }
        public void GetFunctionEntryPoint_WithNamedMethod_ReturnsNamedMethod()
        {
            var resolver = new FunctionEntryPointResolver("NamedMethod");

            var method = resolver.GetFunctionEntryPoint(new[]
           {
                new TestMethodReference("NamedMethod", true),
                new TestMethodReference("Run", true),
                new TestMethodReference("Run", true),
                new TestMethodReference("PrivateMethodName", false),
            });

            Assert.NotNull(method);
            Assert.Equal("NamedMethod", method.Name);
        }
        public void GetFunctionEntryPoint_WithMissingNamedMethod_ThrowsCompilationException()
        {
            var resolver = new FunctionEntryPointResolver("NamedMethod");

            CompilationErrorException exc = Assert.Throws(typeof(CompilationErrorException), () => resolver.GetFunctionEntryPoint(new[]
             {
                new TestMethodReference("Method1", true),
                new TestMethodReference("Method2", true),
                new TestMethodReference("NamedMethod", false)
            })) as CompilationErrorException;

            var diagnostic = exc.Diagnostics.First();
            Assert.Equal(DotNetConstants.InvalidEntryPointNameCompilationCode, diagnostic.Id);
        }